[freetds] unixODBC via FreeTDS, PHP and Stored Procedure Help

Lowden, James K LowdenJK at bernstein.com
Thu Jul 1 17:04:25 EDT 2004

> From: Joseph Geiser
> Sent: July 1, 2004 4:46 PM
> > We now have a db-lib test facility: bsqldb, first included in 
> > 0.62.3.  (If you want a man page, though, get a nightly 
> > snapshot.)  The attached script works with bsqldb; I'd be 
> > curious to know if isql can process it, too.  But: all it's 
> > doing is T-SQL.  If you use the -v option, bsqldb will show 
> > you that no parameters are returned as such to the client.  
> Just an FYI... here are the results of this test (some data 
> modified for obvious reasons)
> [joe at server www]# bsqldb -S server -U sa -P pass -D dbname -i 
> odbctest-bsql
> -o odbctest-bsql-out -v
> bsqldb:157: Verbose operation enabled
> bsqldb:207: Query:
>         declare @cid cursor, at rcid int, at rpid int, at rtid varchar(20)
>         exec mt_testhash @hashin='1h88f9', at hashdata=@cid output
>         fetch next from @cid into @rcid, at rpid, at rtid
>         while @@fetch_status=0
>         begin
>           print cast(@rcid as varchar(10)) + ' - ' + cast(@rpid as
> varchar(10)) + ' - ' + @rtid
>           fetch next from @cid into @rcid, at rpid, at rtid
>         end
>         close @cid
>         deallocate @cid
> bsqldb:180: dbsqlsend() OK:
> bsqldb:188: dbsqlok() OK:
> bsqldb:261: calling dbresults OK:
> Result set 1
> Freeing prior allocations
> Allocating buffers
> Allocating compute buffers
> Metadata
> col     name                            source                
>           type
> size    varys
> ------  ------------------------------  ------------------------------
> ---------------  ------  ------
> Data
> Retrieving return status... Procedure returned 0
> 1 rows affected
> Retrieving output parameters... none
> bsqldb:583: dbresults() returned NO_MORE_RESULTS (2):
> Is this what should be expected?  

Yes.  The output of the PRINT statement should have landed in odbctest-bsql-out.  The -v output is written to stderr.  Because the code runs in bsqldb, I'd expect it to work with PHP using the mssql extension.  

This line:

> Retrieving output parameters... none

indicates that the server did not return any output parameter values to the client (cf. dbnumrets).    

However, your example doesn't show any output parameters that you could bind.  @cid is of type cursor, and it's the output parameter for mt_testhash.  You won't be able to return a cursor variable to your PHP program.  Not that I can see any real reason to....

I hope that answers your question.


The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.

More information about the FreeTDS mailing list