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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Branching logic in PL/SQL, positive instead of exception

Re: Branching logic in PL/SQL, positive instead of exception

From: Paul Heely <pheely_at_acm.org>
Date: Fri, 15 Mar 2002 18:03:27 -0800
Message-ID: <F001.0042B45D.20020315180327@fatcity.com>


RE: Branching logic in PL/SQL, positive instead of exceptionDoesn't a cursor loop only process the loop body when records are found? If this is true then you will never execute the loop body when the %notfound condition is true, control has already passed to the next statement following the for loop.

--

Paul

As an extension of this conversation, if I have eight conditional queries, eg.:
for i_row in main loop

   build sql
   declare cursor a select stuff
   for a_row in a loop
   if a%found

      do stuff
   elsif a%notfound

         declare cursor b select stuff
         for b_row in b loop
         if b%found
             do stuff
         elsif b%notfound
               declare cursor c select stuff
               for c_row in c loop

I'm having trouble with the %notfound and passing control. Do you see what I've done wrong?
Thanks, Linda

-----Original Message-----

Sent: Wednesday, March 13, 2002 2:39 PM
To: Multiple recipients of list ORACLE-L

Use SQL%found
It's in the manual. :)
Jared

"Hagedorn, Linda" <lindah_at_epocrates.com> Sent by: root_at_fatcity.com
03/13/02 12:34 PM
Please respond to ORACLE-L

        To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
        cc:
        Subject:        Branching logic in PL/SQL, positive instead of
exception

Hello,
I'm looking for an example of structured PL/SQL code that does not use exception logic for branching, but instead recognizes that data is found. As a bad example,
 Select col1 from test.table t where exists (select z.zip from zip_table z where t.zip=z.zip ) into v_col1 ;
 exception
 when no_data_found
   begin
   select col2 from test.table2 t2 where exists (select z.zip from zip_table z where t2.zip=z.zip) into v_col1 ; ;

   exception
   when no_data_found
     begin
I've checked the books and cannot see how to test for a positive result instead of a negative (exception) result. Does anyone have a good example of branching logic on record found? Thanks, Linda

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Jared.Still_at_radisys.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Paul Heely
  INET: pheely_at_acm.org

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists

--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Mar 15 2002 - 20:03:27 CST

Original text of this message

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