Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is MySQL stored procedure transactional by default?

I have a MySQL stored procedure which reads and updates multiple tables, so I want it to be a transaction. Is it already transactional by default? Or do i need to do something?

MySQL 5.0+

like image 431
Dagang Avatar asked Dec 27 '25 21:12

Dagang


1 Answers

I don't believe so. According to the manual section on BEGIN...END statements:

Within all stored programs (stored procedures and functions, triggers, and events), the parser treats BEGIN [WORK] as the beginning of a BEGIN ... END block. Begin a transaction in this context with START TRANSACTION instead.

Also see the manual on START TRANSACTION, COMMIT, and ROLLBACK Syntax.

like image 191
Ted Hopp Avatar answered Dec 30 '25 16:12

Ted Hopp