How handling error in functon and return null instead any errors?
Simple example:
create or replace Function MY_FUNC
(
p_par IN number
)
RETURN varchar2
IS
BEGIN
return (Select name from my_table where id = p_par);
END;
create or replace Function MY_FUNC
(
p_year IN number,
p_month IN number,
p_day IN number
)
RETURN varchar2
IS
v_return varchar2(100);
BEGIN
Select to_char(p_day)||''||substr(to_char(TO_DATE(p_year || '-' || p_month || '-' || p_day, 'YYYY-MM-DD'),'DY'),0,1) into v_return from dual;
return v_return;
END;
Select MY_FUNC(2021,6,30) from dual; --OK
Select MY_FUNC(2021,6,31) from dual; --Need catch error
Return null if don't have record in table, or return null on ORA-01839: date not valid for month specified for anything.
p_paris a number, I assumeidis a number,nameis presumably avarchar2