I have a PL/SQL script where it runs a bunch of commands, and calls commit at the very end.
select count(*) into countCol from USER_TAB_COLUMNS where TABLE_NAME = 'EVAPP_CARLETON_RESULT' and COLUMN_NAME = 'AMTFIN' and DATA_SCALE is null;
IF (countCol <> 0) then
execute immediate 'alter table EVAPP_CARLETON_RESULT add AMTFIN_TMP NUMBER(10,2)' ;
execute immediate 'update EVAPP_CARLETON_RESULT set AMTFIN_TMP = AMTFIN' ;
execute immediate 'alter table EVAPP_CARLETON_RESULT drop column AMTFIN' ;
execute immediate 'alter table EVAPP_CARLETON_RESULT rename column AMTFIN_TMP to AMTFIN' ;
DBMS_OUTPUT.put_line('This column EVAPP_CARLETON_RESULT.AMTFIN has been modified to the required precision');
END IF;
logger('68');
evaluate.commitScript;
There are 68 such blocks prior to this but evaluate.commitScript is called at the very end.
But, logger is called after every such block, and it has a commit statement inside of it.
create or replace
PROCEDURE LOGGER
(MESSAGE1 IN VARCHAR2 ) AS
pragma autonomous_transaction;
BEGIN
insert into message_log (datetime, message) values (sysdate, message1);
commit;
END LOGGER;
The commit commits all changes simultaneously. Not just the changes made by the procedure. Is there anyway, we can call commit selectively?
It looks like you already have the solution with this line in the LOGGER proc:
That statement sets a separate transaction within the procedure. The COMMIT issued there will not commit any transactions outside of that procedure.
Also, the DDL in the EXECUTE IMMEDIATE statements are implicitly committed.