Hi,
I have a Stored Procedure like this:
Procedure VES_PROCS.ASDA
(p_cmpny_id IN char,
p_ret_code OUT number);
IS
BEGIN
Select
VA.Vndr_No as VendorNo ,
SGV.Vndr_Nm as VendorName ,
VA.Ref_No
Get_Terms( 'S ' , va.ref_no) as Terms,
from Vndr_Att VA , SG_Vendor SGV
where VA.SGV_No = SGV.SGV_No
and VA.cmpny_id = 'S '
order by vndr_no
P_ret_Code := 0;
EXCEPTION
WHEN Others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || SQLERRM);
P_ret_code := 99;
END;
Get_Terms is a function that Concatenates the Terms into a string from another table:
Function GET_TERMS
( a_cmpny_id vndr_att.cmpny_id%type,
a_ref_no vndr_att.ref_no%type)
RETURN varchar2 IS
v_Terms_Str varchar2(30000);
BEGIN
FOR TermRec IN (SELECT T.Term_nm
FROM VES.Vendor_Terms VT,
VES.Terms T
WHERE (VT.Cmpny_ID = a_Cmpny_ID
AND VT.REF_NO = a_REF_NO
AND VT.Term_ID = T.Term_ID)
ORDER BY T.Term_Nm) LOOP
if v_Terms_str is null then
v_Terms_str := TermRec.Term_Nm ;
else
v_Terms_Str := v_Terms_Str || ', ' || TermRec.Term_Nm ;
end if;
END LOOP;
RETURN v_Terms_Str;
EXCEPTION
WHEN OTHERS THEN
Raise_Application_error(-20393,’Error Occurred in the Function’);
END;
I’m calling the above Stored Procedure from a VB Application.
If the function fails, is there a way to trap that error in the Stored Procedure that calls this function?
Right now,the Stored Procedure does not trap the error created by the function and still holds a 0 in the OUTPUT Paramter p_ret_code (may be because the function is embedded in a SELECT Statement). But after the stored procedure has been executed, when the control goes back to the VB application , it errors out in the application.
If the function fails, how to handle the errorin the stored procedure?
Your help will be greatly appreciated.
Thanks.
I have a Stored Procedure like this:
Procedure VES_PROCS.ASDA
(p_cmpny_id IN char,
p_ret_code OUT number);
IS
BEGIN
Select
VA.Vndr_No as VendorNo ,
SGV.Vndr_Nm as VendorName ,
VA.Ref_No
Get_Terms( 'S ' , va.ref_no) as Terms,
from Vndr_Att VA , SG_Vendor SGV
where VA.SGV_No = SGV.SGV_No
and VA.cmpny_id = 'S '
order by vndr_no
P_ret_Code := 0;
EXCEPTION
WHEN Others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || SQLERRM);
P_ret_code := 99;
END;
Get_Terms is a function that Concatenates the Terms into a string from another table:
Function GET_TERMS
( a_cmpny_id vndr_att.cmpny_id%type,
a_ref_no vndr_att.ref_no%type)
RETURN varchar2 IS
v_Terms_Str varchar2(30000);
BEGIN
FOR TermRec IN (SELECT T.Term_nm
FROM VES.Vendor_Terms VT,
VES.Terms T
WHERE (VT.Cmpny_ID = a_Cmpny_ID
AND VT.REF_NO = a_REF_NO
AND VT.Term_ID = T.Term_ID)
ORDER BY T.Term_Nm) LOOP
if v_Terms_str is null then
v_Terms_str := TermRec.Term_Nm ;
else
v_Terms_Str := v_Terms_Str || ', ' || TermRec.Term_Nm ;
end if;
END LOOP;
RETURN v_Terms_Str;
EXCEPTION
WHEN OTHERS THEN
Raise_Application_error(-20393,’Error Occurred in the Function’);
END;
I’m calling the above Stored Procedure from a VB Application.
If the function fails, is there a way to trap that error in the Stored Procedure that calls this function?
Right now,the Stored Procedure does not trap the error created by the function and still holds a 0 in the OUTPUT Paramter p_ret_code (may be because the function is embedded in a SELECT Statement). But after the stored procedure has been executed, when the control goes back to the VB application , it errors out in the application.
If the function fails, how to handle the errorin the stored procedure?
Your help will be greatly appreciated.
Thanks.