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: Paul Robinson <paul.robinson AT groupbc.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Stored Procedure Output Parameters
  • Date: Tue, 02 Aug 2005 13:13:08 +0100

Thanks Bill.

BOL?? - I don't know what this is.
Presumably there is some documentation somewhere that you are referring to for the dblib API - I've been working on this issue we found (in PHP really rather than FreeTDS) and this seemed the simplest way to solve it. I'm not familiar with the API that is implemented at all. Documentation pointers are always appreciated.

Even if this is the case that wouldn't _necessarily_ give a way of determining the difference between and empty VARCHAR string and a NULL value - would it?

Paul

Thompson, Bill D (London) wrote:
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




Archive powered by MHonArc 2.6.24.

Top of Page