mvchandoo Posted May 8, 2015 Share Posted May 8, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/ Share on other sites More sharing options...
Barand Posted May 8, 2015 Share Posted May 8, 2015 I was wondering if you were having the same problem as in this post http://forums.phpfreaks.com/topic/296012-php-sqlsrv-query-method-giving-strange-blank-results/?do=findComment&comment=1510557 Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/#findComment-1511136 Share on other sites More sharing options...
mvchandoo Posted May 8, 2015 Author Share Posted May 8, 2015 Sorry! My case is different, I am getting zero rows and false on executing via PHP, But, if I execute using sql manager 20 rows are coming. @Guru. Tq. Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/#findComment-1511145 Share on other sites More sharing options...
jcbones Posted May 8, 2015 Share Posted May 8, 2015 (edited) 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 May 8, 2015 by jcbones Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/#findComment-1511158 Share on other sites More sharing options...
jcbones Posted May 8, 2015 Share Posted May 8, 2015 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] Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/#findComment-1511160 Share on other sites More sharing options...
mvchandoo Posted May 12, 2015 Author Share Posted May 12, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/296147-sql-stored-procedure-not-fetching-data-even-though-the-sqlsrv_query-has-no-errors/#findComment-1511506 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.