Forum Stats

  • 3,827,727 Users
  • 2,260,812 Discussions
  • 7,897,362 Comments

Discussions

Error log trigger problem

Latvian83
Latvian83 Member Posts: 51
edited Jul 10, 2015 4:09AM in SQL & PL/SQL

Hello

I am trying to create an error log trigger that records any error caused by a user and to save that error to an error table. First I am creating the table as following:

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));

And then the trigger:

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),TO_CHAR(sysdate, 'YYY:MM:DD HH24:MI:SS'),var_user,
             var_osuser,var_machine,var_process,var_program);
end;

But when I compile the trigger, I get the following errors:

  • Error(12,2): PL/SQL: SQL Statement ignored
  • Error(14,13): PL/SQL: ORA-00942: tabell eller vy finns inte

What am I missing here?

Thanks in advance

Tagged:

Answers

This discussion has been closed.