commit or rollback?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colm Connolly

    #1

    commit or rollback?

    Hi all,

    I'm working with tables stored by the InnoDB engine and would like to
    be able to commit only if there are no errors generated by a group of
    statements like this.

    /* -*- sql -*- */
    SET AUTOCOMMIT=0;
    use db1;
    begin work;
    sql statement 1;
    sql statement 2;
    ..
    ..
    ..
    sql statement n;

    At this point I'd like to say, in sql,
    if no errors then
    commit;
    else
    rollback
    end

    From what I read in the manual I can do one or the other (commit or
    rollback) but there didn't seem to be a way of conditionally doing one
    or the other of them.

    Thanks in advance,

    Colm.
Working...