[freetds] Stored Procedure Output Parameters

Thompson, Bill D (London) bill_d_thompson at ml.com
Tue Aug 2 07:53:55 EDT 2005


Hi Paul,

The BOL entry for dbretdata() suggests:

"To determine whether the data really has a null 
 value (and retnum is not merely out of range), 
 check for a return value of 0 from dbretlen."

we certainly implement dbretlen() which returns the column_cur_size of
the parameter.
This could well be zero in the case of a NULL return parameter, but if
not it could be fixed...

Bill

-----Original Message-----
From: freetds-bounces at lists.ibiblio.org
[mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Paul Robinson
Sent: 02 August 2005 12:09
To: freetds at lists.ibiblio.org
Subject: [freetds] Stored Procedure Output Parameters


We've been trying to use PHP 5.0.4 with FreeTDS 0.63 in order to enable 
communication with a Windows 2000 Server running MS SQL Server 2000.

We ran into problems with input and output parameters that I believe 
I've now solved. In order to do so I have had to change PHP code (which 
I will be submitting as a PHP bug shortly) and I've added an extra 
function to dblib/dblib.c to enable the calling application (PHP in this

case) to determine if the output parameter is NULL.

Diff is as follows:

3972a3973,3990
 > int
 > dbretisnull(DBPROCESS * dbproc, int retnum)
 > {
 >       TDSCOLUMN *colinfo;
 >       TDSPARAMINFO *param_info;
 >       TDSSOCKET *tds;
 >
 >       dbnumrets(dbproc);
 >
 >       tds = (TDSSOCKET *) dbproc->tds_socket;
 >       param_info = tds->param_info;
 >       if (!param_info || !param_info->columns || retnum < 1 || retnum

 > param_info->num_cols)
 >               return NULL;
 >
 >       return tds_get_null(param_info->current_row, retnum - 1);
 > }
 >
 >

I hope you'll either point out a more sensible way that I could have 
implemented this without having to resort to implementing a new function

or you will consider this for inclusion in a future release.

For information the calling code in PHP (ext/mssql/php_mssql.c) looks 
like this (in _mssql_get_sp_result inside the loop over the result
columns):

is_null = dbretisnull(mssql_ptr->link, i);
if (is_null) {
	ZVAL_NULL(bind->zval);
}

Thanks,
	Paul
-- 
Paul Robinson
Systems Manager
Business Collaborator Ltd
WWW: http://www.groupbc.com
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail.     http://www.ml.com/email_terms/
--------------------------------------------------------



More information about the FreeTDS mailing list