Output parameter from MSSQL Stored procedure

From: Date: Mon, 10 Jul 2000 20:37:00 +0000
Subject: Output parameter from MSSQL Stored procedure
Groups: php.db 
Request: Send a blank email to php-db+get-1015@lists.php.net to get a copy of this message
I've been tinkering all day trying to get this to work: I want to call a stored procedure on an MSSQL server. This works fine passing one-way parameters, and also calling a sproc that returns a cursor, however attempting to read an OUTPUT parameter has been a real hair-puller. Has anyone successfully done this? the following code attempts to prepare a statement and then exec it with a three element array called $sqldata[]. The third parameter is supposed to be an output parameter. In VB you need to specify varchar, single, integer, input, output, etc for paramters. The php docs simply show passing an array. Where can I find more information on this? Does anyone know if php will eventually support stored procedures in it's mssql_ command set? -Erik Olson New B <?php function Error_Handler( $msg, $cnx ) { echo "$msg \n"; odbc_close( $cnx ); exit(); } $userid="erik" ; $password="moo" ; $control="5444409"; $lettercode="2"; $vchMessage = " " ; $cnx = odbc_connect( "CustomerCenter", "$userid", "$password" ); if ( ! $cnx ) { Error_Handler( "Error in odbc_connect", $cnx ); } $ex = odbc_prepare( $cnx, "[Customer Center]..spmail_ReturnMail @iApplicationID=?,@tiLetterType=?,@vchMessage=? OUTPUT"); if ( ! $ex ) { Error_Handler( "Error in prepare", $cnx ); } $sqldata = array($control, $lettercode, "@vchMessage"); print("<P> Before: $sqldata[0] $sqldata[1] $sqldata[2]\n"); if ( ! odbc_execute( $ex, &$sqldata) ) { Error_Handler( "Error in odbc_exec.", $cnx ); } print("<P> After: $sqldata[0] $sqldata[1] $sqldata[2]\n"); odbc_close( $cnx ); ?>

« previous php.db (#1015) next »