Jump to content

Recommended Posts

I have a stored procedure with 2 parameters. I'm able to execute stored procedures with one parameter using the same script below. But I couldn't make it work with two parameters.



$stmt = "{CALL VM_GETPRs_CAMPS (?,?)}";**//SP has 160 rows of data.**

$fdate=date("Y-m-d");
$tdate=date("Y-m-d");

$params = array(
array($fdate,SQLSRV_PARAM_IN),
array($tdate,SQLSRV_PARAM_IN) 
);

$result = sqlsrv_query( $conn, $stmt,$params,array('Scrollable' => 'buffered')); //not getting any error 

if( $result === false) {
die( print_r( sqlsrv_errors(), true) );
} else{
**//**I tried sqlsrv_num_rows and sqlsrv_has_rows sqlsrv_fetch_array all are giving zero rows.**
$row_count = sqlsrv_num_rows( $result ); 
if ($row_count === false)
echo "No rows";
else if ($row_count >=0)
echo "\n$row_count\n"; //outputs 0
----------------------------------
if(sqlsrv_has_rows($result))
echo "has rows";
else
echo "No rows"; //outputs No rows
----------------------------------
$data = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
    var_dump($data); //outputs bool(false)

I'm looking for a solution since four days. Please help me.

Change this line:

(It shows it like this in the manual, but setting true returns the function as a string, so it wouldn't be printed in a die() or exit().)

die( print_r( sqlsrv_errors(), true) );

To:

die( print_r( sqlsrv_errors()));

Then tell us what errors it is printing out.

Edited by jcbones

This line:

 

$result = sqlsrv_query( $conn, $stmt,$params,array('Scrollable' => 'buffered'));

Should be:

$result = sqlsrv_query( $conn, $stmt,$params,array('Scrollable' =>SQLSRV_CURSOR_BUFFERED)); //not sure it matters.

[/code]

Hi, Guru,

 

It dont have any errors. so, Its not going into the below condition.

die( print_r( sqlsrv_errors()));
SQLSRV_CURSOR_BUFFERED = 'buffered';// both are similar. 

As per my investigation. If the stored procedure have multiple inserts into the tables. Then sqlsrv library is unable to fetch the data from the stored procedure. Hoping its a bug in library it self. Not sure. I am googling it since days.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.