Home » SQL & PL/SQL » SQL & PL/SQL » Database triggers
Database triggers [message #39237] Fri, 28 June 2002 14:15 Go to next message
sharu
Messages: 5
Registered: June 2002
Junior Member
Hi I have a problem :
I have a trigger and when this trigger raises an user defined error say -20001 i want to pass this error message to a procedure. how do i do it ? appreciate ur help

thanks in advance
Re: Database triggers [message #39239 is a reply to message #39237] Fri, 28 June 2002 15:35 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
CREATE TABLE T ( C VARCHAR2 (30) ) ;

CREATE OR REPLACE TRIGGER t_trig
BEFORE INSERT
ON t
FOR EACH ROW
BEGIN
raise_application_error (-20001, 'Error in t_trig');
END;
/

CREATE OR REPLACE PROCEDURE t_proc
IS
v_errm VARCHAR2 (1000);
BEGIN
INSERT INTO t VALUES (1);
EXCEPTION
WHEN OTHERS
THEN
v_errm := SQLERRM; <<== grab it here
DBMS_OUTPUT.put_line ('v_errm= '|| v_errm);
raise_application_error (-20001, 'Error in t_proc ==> ' || v_errm);
END;
/

set serveroutput on

begin
t_proc;
end;
/

v_errm= ORA-20001: Error in t_trig

ORA-20001: Error in t_proc ==> ORA-20001: Error in t_trig
ORA-06512: at "SCOTT.T_TRIG", line 2
ORA-04088: error during execution of trigger 'SCOTT.T_TRIG'
ORA-06512: at "SCOTT.T_PROC", line 11
ORA-06512: at line 2
Previous Topic: Should the order of the where clause affect result sets
Next Topic: HELP!!!!
Goto Forum:
  


Current Time: Thu Apr 25 05:46:09 CDT 2024