Friday, March 9, 2012

Retrieving an integer value from a database function via PHP

I am trying to retrieve an integer value that is returned from an MS SQL function that our DBA wrote and is saved in a table in the database. Using the ODBC_EXEC command I am able to successfully call and execute the function. All I am able to get back is the Resource id. This is the PHP code:

$sqlquery = "dbo.fn_gcc_total_applied '123456'";
$result = odbc_exec($sqlconnect, $sqlquery);
if (!$result) {
exit("Error in SQL 3");
}

Is there a way of capturing the actual integer value that is being returned by the function?

This is an actual function not a stored procedure. The actual MS SQL code is as follows:

declare @.ret_value int

set @.ret_value = dbo.fn_gcc_total_applied ('123456')
print 'Total Applied: ' + cast(@.ret_value as varchar(3))

Thank you in advance for any help you can offer.

Fred BernsteinIn my opinion this has more to do with the MS SQL function and the way the query is setup then with PHP. I therefore think you'll get better support when this thread is moved to the MS SQL forum. Good luck!

Ronald :cool:|||

Quote:

Originally Posted by ronverdonk

In my opinion this has more to do with the MS SQL function and the way the query is setup then with PHP. I therefore think you'll get better support when this thread is moved to the MS SQL forum. Good luck!

Ronald :cool:


Thank you very much for pointing me in the right direction.

Fred Bernstein

No comments:

Post a Comment