trap the time and date of the erorrs

All posts relating to Oracle PL/SQL development.

Moderator: Tim...

trap the time and date of the erorrs

Postby baseballGuy » Tue Jun 05, 2012 2:20 pm

Hi Tim

I have a trigger, below is the code:

create or replace trigger blah
declare
med varchar(30)
begin
dud...
.......
EXCEPTION
WHEN others THEN
dbms_output.enable(100000);
dbms_output.put_line(SQLERRM) ;
error_log;
END;
/

Basically, I want to write the error into the txt file, so I create another procedure called error_log, so everytime if there is an error, it will write to the log file for me. what I want is to captured the data and time of the error b/c right now I can only see the error without knowing when it happened.

Thoughts?
Thanks Tim
baseballGuy
Member
 
Posts: 30
Joined: Thu Mar 22, 2012 7:08 pm

Re: trap the time and date of the erorrs

Postby Tim... » Tue Jun 05, 2012 2:30 pm

Hi.

If it's a row level trigger, you have access to the :new. and :old. attibutes.

Insert:

:new.colname - New value for a named column.

Update:

:new.colname - New value for a named column.
:old.colname - Value for the named column prior to update.

Delete:

:old.colname - Value for the named column prior to delete.

You can use this method for each of the columns in on the trigger table to access and log the data.

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog
Tim...
Site Admin
 
Posts: 17955
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK

Re: trap the time and date of the erorrs

Postby baseballGuy » Tue Jun 05, 2012 3:19 pm

your typing came up with funny sign......
baseballGuy
Member
 
Posts: 30
Joined: Thu Mar 22, 2012 7:08 pm

Re: trap the time and date of the erorrs

Postby Tim... » Tue Jun 05, 2012 3:30 pm

Hi.

I've turned off smilies for that post so you can read it properly. :)

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog
Tim...
Site Admin
 
Posts: 17955
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK


Return to Oracle SQL and PL/SQL Development

Who is online

Users browsing this forum: No registered users and 1 guest