Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Need Help with some PLSQL code please

Re: Need Help with some PLSQL code please

From: andrewst <member14183_at_dbforums.com>
Date: Sat, 13 Sep 2003 12:27:16 -0400
Message-ID: <3366724.1063470436@dbforums.com>

An EXCEPTION raised in the declaration section of a PL/SQL block is not handled by the block's own exception handler. Like these:

TempID VARCHAR2( 50 ) := CHECK_PROCESS_ID( MyNumber ); -- Returns a VARCHAR2

TempDate VARCHAR2( 50 ) := CHECK_MY_DATE( MyDate ); -- Returns a VARCHAR2 Move the assignments into the body if you want to handle them yourself.

Other comments:

  1. Rather than concern yourself with the closing of cursors in the exception handler, why not use a simple FOR loop?

FOR myRow IN MyCursor LOOP

..

END LOOP; (No need to declare MyRow in that case either).

2) I don't like this:

WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE( '-----------------------------------------' );

DBMS_OUTPUT.PUT_LINE( 'Unknown Error Occured. ' );

DBMS_OUTPUT.PUT_LINE( '-----------------------------------------' );



The only reason the error is "unknown" is because you've prevented Oracle from telling you what it is! Why not just use RAISE here?

3) Your CHECK_PROCESS_ID function has 2 different return values, but

   your main program doesn't care about the difference.

--
Posted via http://dbforums.com
Received on Sat Sep 13 2003 - 11:27:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US