Home » SQL & PL/SQL » SQL & PL/SQL » Unreachable Code Error (Oracle 10g)
Unreachable Code Error [message #322407] Fri, 23 May 2008 06:48 Go to next message
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 Go to previous message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
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
Previous Topic: Partitioning an existing table
Next Topic: Please frame a query for this
Goto Forum:
  


Current Time: Wed Dec 07 03:20:27 CST 2016

Total time taken to generate the page: 0.10071 seconds