Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Transactions

Status
Not open for further replies.

Laeg

Programmer
Nov 29, 2004
95
IE
Just a quick sample in MSSQL first to show my point.

Code:
BEGIN TRANSACTION

UPDATE tblFoo set a = 1

IF @@ERROR <> 0
	BEGIN
		RETURN 1
		ROLLBACK TRANSACTION
	END
ELSE
	BEGIN
		UPDATE tblBar set b = 2

		IF @@ERROR <> 0
			BEGIN
				RETURN 1
				ROLLBACK TRANSACTION
			END
		ELSE
			BEGIN
				RETURN 1
				COMMIT TRANSACTION
			END
	END

END

So in this instance @@ERROR catches ANY possible associated errors with the first
update statment, if any exist the statement is rolled back but if it is squeaky
clean then we head on to the next statement. How do I achieve this kind of
cascading block check in MySQL, I mean what is the equivalent of @@ERROR that
I can wrap in conditional statements?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top