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?!?
--------------------
Chcete ADSL na mesic zdarma? http://user.centrum.cz/redir.php?url=http://www.in192.cz
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php