mysql - Seeking an example of a procedure that uses row_count -


i want write procedure handle insert of data 2 tables. if insert should fail in either 1 whole procedure should fail. i've tried many different ways , cannot work. i've purposefully made second insert fail data inserted first table anyway.

i've tried nest if statements based on rowcount though data fails on second insert, data still being inserted first table. i'm looking total number of 2 affected rows.

can please show me how handle multiple inserts , rollback if 1 of them fails? short example nice.

if using innodb tables (or other compatible engine) can use transaction feature of mysql allows want.

  • basically start transaction
  • do queries checking result
  • if every result ok call conmit
  • else call rollback void queries within transaction.

you can read , article examples here.

hth!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -