Search notes:

Oracle PL/SQL: Logger procedure with PRAGMA AUTONOMOUS_TRANSACTION

Log Table

create table tq84_log_table (
   txt     varchar2(4000)    not null,
   id      number(10)        generated by default on null as identity primary key,
   ts      timestamp         default systimestamp
);

Logging Procedure

create or replace procedure tq84_log(t varchar2) authid definer as
   pragma autonomous_transaction;
begin
   insert into tq84_log_table(txt) values (t);
   commit;
end tq84_log;
/

Log View

create or replace view tq84_log_view as
select
   txt,
   extract(day    from (systimestamp - ts)) days_ago   ,
   extract(hour   from (systimestamp - ts)) hours_ago  ,
   extract(minute from (systimestamp - ts)) minutes_ago,
   extract(second from (systimestamp - ts)) seconcs_ago,
   id
from
   tq84_log_table
order by
   id desc;

Cleaning up

drop view      tq84_log_view;
drop table     tq84_log_table;
drop procedure tq84_log;

See also

pragma autonomous_transaction
Log files

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759398087, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/PL-SQL/pragma/autonomous_transaction/logger(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78