Home » SQL & PL/SQL » SQL & PL/SQL » Display the error thrown by a SQL statement using a PLSQL trigger. (ORACLE 10g, Win 2003)
Display the error thrown by a SQL statement using a PLSQL trigger. [message #289688] Tue, 25 December 2007 06:31 Go to next message
gokul_ifs
Messages: 41
Registered: March 2006
Location: india
Member
Hi,

My requirement is if a SQL query tries to update a primary key in a table then it has to fire a trigger which will display some user defined description for that error.

The error code should come from an error log table like (Error#, Error description).

Let me also know whether there is any option in oracle to catch the error code thrown by a SQL query and get the description for the corresponding error description.

Help to complete trigger is appreciated.

Cheers,
GOKUL
Re: Display the error thrown by a SQL statement using a PLSQL trigger. [message #289689 is a reply to message #289688] Tue, 25 December 2007 06:40 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

You can use "sqlcode" or "sqlerrm" funtion to capture oracle error message.

SQLCODE
http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/13_elems049.htm#LNPLS01349

SQLERRM
http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/13_elems050.htm#LNPLS01350
Re: Display the error thrown by a SQL statement using a PLSQL trigger. [message #289696 is a reply to message #289688] Tue, 25 December 2007 09:37 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It depends of your application/language.
In PL/SQL sue an EXCEPTION block.

Regards
Michel
Previous Topic: Using sql object types as an out parameter to a procedure
Next Topic: sql script is not working in unix box
Goto Forum:
  


Current Time: Sat Dec 10 08:44:33 CST 2016

Total time taken to generate the page: 0.04534 seconds