Exception messages [message #361047] |
Mon, 24 November 2008 23:31 |
prashas_d
Messages: 66 Registered: February 2007
|
Member |
|
|
Hi All,
I have a requirement that the oracle procedure should raise an exception with the user defined error messages whenever any validations are failed.
Here is the sample procedure that throws an exception when the input argument is null.
create or replace PROCEDURE testException( a in varchar2) as
INPUT_ARGUMENT_NULL EXCEPTION;
BEGIN
IF a is null then
raise INPUT_ARGUMENT_NULL;
END IF;
dbms_output.put_line('No Exception raised');
EXCEPTION
WHEN INPUT_ARGUMENT_NULL THEN
raise_application_error(-20001,'INPUT ARGUMENT PASSED AS NULL');
END testException;
Calling the procedure...
SQL> EXECUTE TESTEXCEPTION(NULL);
begin TESTEXCEPTION(NULL); end;
ORA-20001: INPUT ARGUMENT PASSED AS NULL
ORA-06512: at "PTTDEV01.TESTEXCEPTION", line 10
ORA-06512: at line 1
But here along with the user defined message "INPUT ARGUMENT PASSED AS NULL", it is also showing messages of "ORA-06512: at "PTTDEV01.TESTEXCEPTION", line 10" & "ORA-06512: at line 1"
What I need is it should simply give error message as either "ORA-20001: INPUT ARGUMENT PASSED AS NULL" but not the rest of the lines.
Can someone please let me know how to achieve it?
Thanks in advance.
prashas_d
|
|
|
|
|
|
|
Re: Exception messages [message #361192 is a reply to message #361097] |
Tue, 25 November 2008 05:44 |
prashas_d
Messages: 66 Registered: February 2007
|
Member |
|
|
Thanks for the responses!!
It is the third party GUI application(developed by client) which is suppose to call my procedure.
We have informed them to use sqlerrm to get only the actual error message.
prashas_d.
|
|
|