Oracle database tips logo
Article categories | Blog and News Page | SQL | SQL*Plus | DBA Scripts | Standby dbs | Database Links | Techno webcasts | Oracle Magazine | Free IT Magazines | Oracle Database Hosting Companies | Site Search |
RSS
XML RSS
What is this?
AddThis Feed Button

Social Bookmarking
- Found on the internet ! -

Oracle workbooks

Download Oracle Books



- Featured ebook -

Database Normalization
by Alf Pedersen

Database Normalization ebook Understand and master how to normalize a database using methods richly documented with graphical ERD and server diagram examples

NoAdware Free Trial

NoAdware Remove
harmful
adware,
spyware,
trojans,
dialers
and worms!
-- FREE --
IT Magazine
Subscriptions

WebSite Magazine WebSite Magazine Practical advice, helpful tools and insights for website owners

Oracle Magazine Oracle Magazine Contains technology strategy articles, sample code, tips, Oracle and partner news, how-to articles for developers and DBAs

Dr Dobb's Journal Dr Dobb's Journal enables coders to write the most efficient programs and help in daily programming quandaries

DM Review DM Review is recognized as the premier business intelligence, analytics and data warehousing publication
Various other Free IT magazine subscriptions

Raise Alertlog Error


Always test these 'Raise Alertlog error' commands on a test server
before implementing them on a production server.

Came across this very handy utility recently.

Warning, it is unsupported by Oracle, so don't base your mission-critical alerts on this method.

Let's say you are creating a stored proc as user scott, and instead of writing your
trapped error message to a table, an error file or sending an email, you would like it to be reflected
in the database's alert.log.

The steps below show you how.

If not documented, this is guaranteed to make you unpopular with DBAs who manage your database in your absence...


First, grant execution privileges to scott:

as sys:

SQL> grant execute on sys.dbms_system to scott;

Grant succeeded.



Now run and test a procedure which will write to the alert.log

declare
Mess varchar2(200);
begin
Mess := 'ORA-USER_ERROR'||', scott.test_proc, '||', '||substr(SQLERRM,1,100);
sys.dbms_system.ksdwrt(2,Mess);
commit;
end;



This is how it reflects in the alert.log (ORA-0000 because there is no error.)

Thu Jan 24 14:57:15 2008
ORA-USER_ERROR, scott.test_proc, ORA-0000: normal, successful completion


Lastly : implement it in your procedure's exception handler section:

...
exception
when others then
Mess := 'ORA-USER_ERROR'||', scott.test_proc, '||', '||substr(SQLERRM,1,100);
sys.dbms_system.ksdwrt(2,Mess);
commit;
....





Return from raise alertlog error back to oracle-script-tutorials.