DROP TRIGGER log_errors_trig;
DROP TABLE log_errors_tab;
CREATE TABLE log_errors_tab (
error VARCHAR2(30),
TIMESTAMP DATE,
username VARCHAR2(30),
osuser VARCHAR2(30),
machine VARCHAR2(64),
process VARCHAR2(8),
program VARCHAR2(48));
CREATE OR REPLACE TRIGGER log_errors_trig
after servererror ON database
DECLARE
var_user VARCHAR2(30);
var_osuser VARCHAR2(30);
var_machine VARCHAR2(64);
var_process VARCHAR2(8);
var_program VARCHAR2(48);
BEGIN
SELECT username, osuser, machine, process, program
INTO var_user, var_osuser, var_machine, var_process, var_program
FROM sys.v_$session
WHERE audsid = USERENV('sessionid');
INSERT INTO log_errors_tab
VALUES(dbms_standard.server_error(1),SYSDATE,var_user,
var_osuser,var_machine,var_process,var_program);
END;