mssql_query & ROLLBACK

From: Date: Mon, 24 Mar 2003 14:27:12 +0000
Subject: mssql_query & ROLLBACK
Groups: php.db 
Request: Send a blank email to php-db+get-26600@lists.php.net to get a copy of this message
I have an opened connection to MS SQL Server 7 and I try to do this: $commit = FALSE; // SELECT @@TRANCOUNT returns 0 here = OK if(mssql_query("BEGIN TRANSACTION")) { // SELECT @@TRANCOUNT returns 1 here = OK if(mssql_query("INSERT INTO TABLE (DATE) VALUES ('$date')")) { // ... $commit = TRUE; } if($commit) { mssql_query("COMMIT TRANSACTION"); return TRUE; } else { mssql_query("ROLLBACK TRANSACTION"); return FALSE; } } else return FALSE; When INSERT is done without errors, everything is OK. But when it is not possible to insert data into a table for any reason, SQL server returns this error message: The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. (severity 16) in ... .php But using SELECT @@TRANCOUNT I can check that TRANSACTION is started, I tried to name the transaction, it didn't help. I thought it is because I can't COMMIT/ROLLBACK empty transaction, but this works fine: mssql_query("BEGIN TRANSACTION"); mssql_query("ROLLBACK TRANSACTION"); What's wrong?!? -------------------- Změň se díky novým, barevným čočkám FreshLook! Nyní akční nabídka. http://user.centrum.cz/redir.php?url=http://www.cibavision.cz

« previous php.db (#26600) next »