Jump to content

mssql_query always fail after a problem in a stored procedure in a transaction


Recommended Posts

Hi,

 

I'm currently trying to write a script which connects to a mssql database (sql server 2005) and it starts a transaction.

 

I calls some stored procedures. (as this is an integration project, most of the sql queries are called as stored procedures instead of stand alone sql queries.) If an error occurs on a stored procedure, mssql_query function seems to return false on every sql query I'm sending.

 

I do not understand why such a thing happens. Is there anyone who had encountered such an issue.

 

thanks.

Ok then here is part of the code:

 

<?php
//Some connection queries are coming here...
$res = mssql_query("EXEC SP_CAUSING_ERROR");
if (!$res) {
  logSomething();
}

$res2 = mssql_query("SELECT * FROM foo"); //The res2 is false...
if (!$res2) {
  //$res2 is false, even the query is valid and should had to return a valid result.
}
?>

 

Connection seem to be fine but once an error occurs on the stored

procedures, mssql_query never executes the query and always return

false.

 

Note that the second sql query is valid. Has no syntax error or something else. It works pretty well if I silence the execution of the stored procedure.

 

There is a working connection. On a sql server 2005 profiler I see that "Begin Transaction" command and the second query (the stored procedure) reaches to the database but the rest of it. Connection does not seem be to be closed because if I var_dump($con) it shows the sybase something and not false.

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.