Mark function with 'pragma autonomous_transaction'
SQL> create table emp (
2 empno number(10),
3 viewed date );
Table created.
SQL>
SQL> create or replace function AUDIT_ROW(id number) return number is
2 begin
3 insert into emp values (id, sysdate);
4 return 0;
5 end;
6 /
Function created.
SQL> show errors
No errors.
SQL>
SQL> create or replace function AUDIT_ROW(id number) return number is
2 pragma autonomous_transaction;
3 begin
4 insert into emp values (id, sysdate);
5 commit;
6 return 0;
7 end;
8 /
Function created.
SQL> show errors
No errors.
SQL>
SQL> drop table emp;
Table dropped.
Related examples in the same category