CREATE PROCEDURE sp_rowcount()
DYNAMIC RESULT SETS 1
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%';
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?
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 ...
insert into dept(deptno,desc) values('100','Sample Dept')
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 ..
Visit the new-look IDUG Website , register to gain access to the excellent content.