Re: Keep inserted rows in Temp table - after a rollback
Hi,
I think savepoint does not work. because insert/update to hard tables and temporary tables is inside a loop(which iterates a cursor).
here is my actual sampel stored procedure. if i put savepoint in loop and if exceptions occurs at nth iterations then it will either rollback or commit all executions before nth iterations.
CREATE PROCEDURE CustomerCleanup()
BEGIN
CREATE TEMPORARY TABLE log(logmessage LONGTEXT);
BLOCK1:BEGIN
DECLARE tableName_cursor CURSOR FOR SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finishedTables = TRUE;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
-- GET DIAGNOSTICS 1 msg = MESSAGE_TEXT;
INSERT INTO temptable VALUES('Rolling back transaction ');
ROLLBACK ;
END;
START TRANSACTION;
tableProcess: repeat
FETCH tableName_cursor INTO tablename;
//insert into table1
//insert into table2
INSERT INTO temptable(logMessage) VALUES ('log message '));
UNTIL finishedTables END REPEAT tableProcess;
COMMIT;
END BLOCK1;
select * from temptable;
END;
Subject
Views
Written By
Posted
1288
February 01, 2019 04:36AM
1021
February 01, 2019 04:44AM
466
February 01, 2019 10:14AM
Re: Keep inserted rows in Temp table - after a rollback
565
February 03, 2019 11:43PM
500
February 04, 2019 11:20AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.