Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to handle function exception when a null value or wrong datatype passed

594752Oct 10 2007 — edited Oct 11 2007

I created this function and it works fine except when a null value or a bad data type (like character data) is passed to it. I have looked all over the place in documentation, but must have missed all the right places. Any hints?

create or replace function vendor_ocn (get_vendor_id in rpt_ds1_cnt_cat.vendor_id%type) return varchar2 is
v_ocn varchar2(3);
begin
 select OCN into v_ocn from rpt_ds1_vend_ocn where vendor_id = get_vendor_id;
 return v_ocn;
exception
 when others then
 return 'XXX';
end;

-----
I want it to return 'XXX' if a null value or any bad data is passed, not only if there is no data returned from the SELECT statement, which now works fine.

Message was edited by:
duanecwilson

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2007
Added on Oct 10 2007
15 comments
3,874 views