Unreachable Code Error [message #322407] |
Fri, 23 May 2008 06:48  |
me_arindam
Messages: 26 Registered: March 2008 Location: India
|
Junior Member |
|
|
Hi All,
I am pasting my procedure(from a package) code below(Here the CursorType is well defined within the package):
PROCEDURE P_TEST (
P_ID IN NUMBER,
P_T_ID IN NUMBER ,
P_RETURN_CODE OUT VARCHAR2,
P_CUR OUT CursorType
)
IS
V_CNT NUMBER;
BEGIN
SELECT NVL(COUNT(*), 0) INTO V_CNT
FROM TABLE1
WHERE UPPER(TRIM(CA_ID)) = UPPER(TRIM(P_ID))
AND UPPER(TRIM(TER_ID)) = UPPER(TRIM(P_T_ID));
IF V_CNT > 0 THEN
OPEN P_CUR FOR
SELECT * FROM TABLE1
WHERE UPPER(TRIM(CA_ID)) = UPPER(TRIM(P_ID))
AND UPPER(TRIM(TER_ID)) = UPPER(TRIM(P_T_ID))
ORDER BY F_NAME;
P_RETURN_CODE := 'SUCCESS';
ELSE
P_RETURN_CODE := 'NO_RECS_FOUND';
OPEN P_CUR FOR SELECT NULL FROM DUAL;
RETURN; -- causing error
END IF;
END;
This is working fine in Oracle 9i. But the same thing is giving
"Unreachable Code" error in Oracle 10g.
If I omit the RETURN clause from the ELSE part( commented in side) then it works fine.
Could anyone please explain.
Again whenever I am running the code in 10g it is asking that NOCOPY should be used for OUT parameter declaration.
It will be very helpful if somebody explain.
Thanks,
Arindam
|
|
|
Re: Unreachable Code Error [message #322413 is a reply to message #322407] |
Fri, 23 May 2008 07:26  |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
1/ As already been said to you:
please read OraFAQ Forum Guide, "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.
2/ 10g is far better PL/SQL compiler than before. It rewrote your procedure to optimize it accordingly to the settings you use. It clearly saw that this statement is useless. Thanks to it.
3/ Oracle returns you warnings/errors accordinfly to what you ask it.
Regards
Michel
|
|
|