Wednesday, 15 February 2012

sql server 2008 - Get the resultset of a function with sqlsrv and PHP -


There is a function in my SQL Server 2008, which returns a resellet and some output variable.

From PHP, I need to get value with sqlsrv library.

I have this code, which I tested with a stored procedure and worked fine.

  & lt ;? Php $ serverName = "(local) \ MSSQLSERVER, 1433"; $ ConnectionInfo = array ("database" = & gt; "xxxx", "UID" => "xxxx", "PWD" => "xxxx"); $ Conn = sqlsrv_connect ($ serverName, $ connectionInfo); If (! $ Conn) {dead (;); } $ Tsql_callSP = "call {my_function (?,?)}"; $ Ret_cod = ""; $ Ret_desc = ""; $ Params = array (array ($ ret_cod, SQLSRV_PARAM_OUT), array ($ ret_desc, SQLSRV_PARAM_OUT)); $ Stmt = sqlsrv_query ($ conn, $ tsql_callSP, $ params); If ($ stmt === incorrect) {debug ("error in executing statement"); Die (debugs (sqlsrv_errors (), true)); } The error result is: 

[microsoft] [odbc driver for SDC server 11] [sql server] 'my_function' for error message . 'My_function' is with a reluctant laugh

I know there is a syntax error, but how do I do this? Find examples on the Internet.

Try I,

$ tsql_callSP = "? = {Call_my_function (?,?)}";

/ html>

No comments:

Post a Comment