Subject | How to interrupt stored procedure "politely" and rollback all changes? |
---|---|
Author | un_spoken |
Post date | 2013-02-25T18:53:08Z |
Hi guys.
Consider such example:
SET TERM ^ ;
CREATE PROCEDURE DO_SOMETHING()
RETURNS
(RESULT INTEGER)
AS
DECLARE VARIABLE V_ITEM_ID;
DECLARE VARIABLe P_RESULT;
BEGIN
RESULT = 1;
--some moedifications in tables here
FOR SELECT ITEM_ID FROM ITEMS INTO :V_ITEM_ID DO
BEGIN
--other_proc also is modifying some tables.
EXECUTE PROCEDURE OTHER_PROC(:V_ITEM_ID)
RETURNING_VALUES(:P_RESULT);
IF (:P_RESULT) = 2 THEN
BEGIN
--Rollback all changes done by DO_SOMETHING and OTHER_PROC
RESULT = :P_RESULT;
--stop processing procedure
END
END
END^
SET TERM ; ^
In other words, can I rollback all changes done by those two procedures without throwing out an exception?
Thank you for your time.
Consider such example:
SET TERM ^ ;
CREATE PROCEDURE DO_SOMETHING()
RETURNS
(RESULT INTEGER)
AS
DECLARE VARIABLE V_ITEM_ID;
DECLARE VARIABLe P_RESULT;
BEGIN
RESULT = 1;
--some moedifications in tables here
FOR SELECT ITEM_ID FROM ITEMS INTO :V_ITEM_ID DO
BEGIN
--other_proc also is modifying some tables.
EXECUTE PROCEDURE OTHER_PROC(:V_ITEM_ID)
RETURNING_VALUES(:P_RESULT);
IF (:P_RESULT) = 2 THEN
BEGIN
--Rollback all changes done by DO_SOMETHING and OTHER_PROC
RESULT = :P_RESULT;
--stop processing procedure
END
END
END^
SET TERM ; ^
In other words, can I rollback all changes done by those two procedures without throwing out an exception?
Thank you for your time.