php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8022 mssql_query seems to be fail with sql statement "set"
Submitted: 2000-11-28 22:41 UTC Modified: 2000-11-29 20:18 UTC
From: lingc at mail dot nsysu dot edu dot tw Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.3pl1 OS: winnt 4.0 sp4+apache1.3.14+mssql
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 + 13 = ?
Subscribe to this entry?

 
 [2000-11-28 22:41 UTC] lingc at mail dot nsysu dot edu dot tw
I need to exec my sql statement with "set nocount on" and "set nocount off" within the for-loop by the function of mssql_query. But it seems only to be successful at the first time and the others were failed with the error message "MSSQL Query Failed". My platform is WinNT4.0sp4+Apache1.3.14+Php4.03pl1+MSSQL7.0sp2. The sql-statement is
<pre>
 $db = mssql_connect("test","","");
 for ($i=0;$i<=3;$i++){
     $SQLstr = "set nocount on
                select news from table_news 
                set nocount off";
     $result = mssql_query($SQLstr,$db);
     print $result;
 }
 mssql_close($db);

========================
The result is:
 1
 Warning: MS SQL: Query failed in c:\test.php3 on line 16
 Warning: MS SQL: Query failed in c:\test.php3 on line 16
</pre>
I use the mssql profiler to trace the execution. I found that the sql statement was only executed at the first time and another times were not found. Is this is a bug of mssql_query ?

Thanks anyway,

Vicent,Lin.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-29 12:13 UTC] fmk@php.net
Divide your query into three.
You dont need to set options at each query. Options should be ste once in each session.
 [2000-11-29 20:18 UTC] lingc at mail dot nsysu dot edu dot tw
There is some supplement about this problem. May be  described sql-statement is not a good example, so it will
confuse the point. There are several SQL-command instead of
the original select query (select news from table),and these
SQL command may be closed by transaction because the query are related. And the for loop is used for several
indep. operations, so set option can't be put outside the loop. 


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC