Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012
    Posts
    8

    Unanswered: DB2 Transaction Control Using Rollback & Commit

    Hi Guys,

    Version: DB2 v9.7.0.3
    OS: AIX
    3rd party: Toad 4.0.1.921(free version)
    I want to implement exception handling and commit/rollback for multiple DML statements, either 3 statements will be successful or all 3 will rolled back;

    Begin
    delete from tab1 where key=1;
    delete from tab2 where key=100;
    delete from tab5 where key=200;
    End;
    --IF EXCEPTION THEN ROLLBACK ELSE COMMIT


    Could you please guide me how to handle the exception with proper syntax?
    thanks in advance

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    how are these statements started - stored proc ? clp ? tool ?
    you can use autocommit off and request a commit at the end if ok
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Structure of SQL procedures - IBM DB2 9.7 for Linux, UNIX, and Windows

    You can use the same logic in a stand-alone compound SQL statement (anonymous block).
    ---
    "It does not work" is not a valid problem statement.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •