Skip to content
Advertisement

Is start transaction always needed with Mariadb storedprocedure?

I have a mariadb database and a stored procedure. If a select statement is true then a delete query is done. Like this:

My question is, do I need to place the start transaction at the beginning before the select statement or is the following possible?

This second code doesn’t require a rollback and only does a start transaction when a alter command is done.

Advertisement

Answer

Why use an IF? Just write this as:

You probably don’t need to wrap this in a transaction, but that might depend on the settings for the database. In general, a single command will be in its own transaction (and there is not much to rollback, actually).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement