Skip to Content.
Sympa Menu

freetds - Re: [freetds] Stored Procedure Output Parameters

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Stored Procedure Output Parameters
  • Date: Tue, 2 Aug 2005 12:53:55 +0100

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/
--------------------------------------------------------




Archive powered by MHonArc 2.6.24.

Top of Page