I want to run an update query against a production database and as good little developer I am trying to make it as safe as possible. I am looking to do the following
BEGIN TRANSACTION UPDATE table_x SET col_y = 'some_value' . . . IF (@@error <> 0) BEGIN ROLLBACK END ELSE BEGIN COMMIT END
The above should work in SQL Server but I need this to work against a MySQL database.
EDIT: Sorry, there is more than 1 statement to execute. Yes I am aware of not needing to wrap a single query in a transaction.
I don’t think this is necessary as there is the concept of implicit commit/rollback.
From MySQL docs: