#40687 [Opn->Bgs]: ODBC+PHP+MSSQL generate error while executing multi query in one transaction
ID: 40687
Updated by: fmk@php.net
Reported By: scottsdev at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: ODBC related
Operating System: Linux
PHP Version: 5.2.1
New Comment:
Your query returns multiple results. The first is for the insert
statement and the second for the select. Take a look at
http://us3.php.net/odbc_next_result to see how to
move to the second
result.
Previous Comments:
------------------------------------------------------------------------
[2007-03-02 00:43:53] scottsdev at gmail dot com
Description:
------------
Hello,
I used DSN to established connection with MSSQL using following Cursor.
Code is >>>
$conn = odbc_pconnect($dsn,$username,$password, SQL_CUR_USE_ODBC) or
die("ERROR OCCUR WHILE CONNECTING TO THE SERVER");
I am getting following error when i tried to execute query like ...
$sql = "insert into <TBL_NAME> (col_1, col_2, col_3) values (val_1,
val_2, val_3); select SCOPE_IDENTITY() as LastInsertedID";
$results = odbc_exec($conn, $sql) or die("<br><pre>Query fail:
$query</pre>");
//////////////////////////////
if(!$results)
{
$this->error("<H2>No results!</H2>\n");
return false;
}else {
$data = array();
while ( $row = odbc_fetch_array($results))
{
$data = $row;
}
odbc_free_result($results);
$last_Id = $data['LastInsertedID'];
}
==================================================
So errors occurs
on this line: while ( $row = odbc_fetch_array($results))
Error is :
Warning: odbc_fetch_array() [function.odbc-fetch-array]: No tuples
available at this result index in
D:\inetpub\wwwroot\php\xyz\lib\xxxx.php on line 11111
So I really don't understand how to remove this error, and what to do
so that such two query can be run at once and return the result.
J. Scott
[scottsdev at gmail dot com]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40687&edit=1
Thread (7 messages)