radalin Posted June 18, 2009 Share Posted June 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/162773-mssql_query-always-fail-after-a-problem-in-a-stored-procedure-in-a-transaction/ Share on other sites More sharing options...
RussellReal Posted June 18, 2009 Share Posted June 18, 2009 you'd hafta show somebody some code to actually get some help lol.. but are you connecting to the database? Quote Link to comment https://forums.phpfreaks.com/topic/162773-mssql_query-always-fail-after-a-problem-in-a-stored-procedure-in-a-transaction/#findComment-858962 Share on other sites More sharing options...
radalin Posted June 18, 2009 Author Share Posted June 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/162773-mssql_query-always-fail-after-a-problem-in-a-stored-procedure-in-a-transaction/#findComment-858977 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.