Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    30

    Arrow Unanswered: Commit Statement

    DB2 Version = 8.1, OS = Windows/Linux

    Example :-

    CREATE PROCEDURE sp_rowcount()
    DYNAMIC RESULT SETS 1
    LANGUAGE SQL
    BEGIN
    DECLARE SQLCODE INT;
    DECLARE v_sqlcode INT DEFAULT 0;
    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION,SQLWARNING,NOT FOUND
    SET v_sqlcode = SQLCODE;

    DELETE FROM employee
    WHERE emp_id LIKE '1%';
    COMMIT;
    END;

    In the above example they had used COMMIT statement after DELETE Query. And my question is, Is it that i have to COMMIT my work after executing queries[INSERT/UPDATE/DELETE] inside stored procedure?
    Can anyone explain the COMMIT statement usage inside DB2 SQL Stored Procedures?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    COMMIT Statement Usage inside a stored procedure is the same as using COMMIT Statements elsewhere ...
    But remember, nesting of UOWs is not allowed in DB2 ie a COMMIT inside a SP applies to the UOW and not just to the SP changes ...
    Eg:
    insert into dept(deptno,desc) values('100','Sample Dept')
    Call sp_rowcount();
    rollback ;

    Here, as there is a commit in the SP, your INSERT is committed ...
    This is the main thing to be considered when coding COMMIT/ROLLBACK inside the SP ..

    HTH

    sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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