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: Select into difficulties

Re: Select into difficulties

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1998/01/15
Message-ID: <34cb1dbd.215279014@inet16>#1/1

On Wed, 14 Jan 1998 16:30:18 GMT, "Laura Bellini" <laura.bellini_at_compaq.com]> wrote:

>Hi.
>
>I am trying to populate a variable via a simple SELECT INTO statement.
>But, if the SELECT INTO returns no rows, I want to populate the variable
>with something else and continue the procedure. I DO NOT want to
>exception-out of the proc. Here is the statement w/in my proc:
>

....
begin

  SELECT	MATCH_PROD_ID  
  INTO		NEW_PROD_ID_OUT
  FROM		PRODUCT_UP-CROSS_SELL
  WHERE	PRODUCT_UP-CROSS_SELL.BASE_PROD_ID = PROD_ID_IN
  AND	PRODUCT_UP_CROSS_SELL.MATCH_TYPE = 'U';
exception
  when no_data_found then new_prod_id_out := prod_id_in; end;
....

will do it. just catch and handle the exception right there at the statement level.

>
>PROD_ID_IN is an incoming parameter.
>If the above returns no rows, I just want to populate NEW_PROD_ID_OUT with
>PROD_ID_IN.
>
>Very simple, I think, but I'm unable to determine a way of doing it.
>
>thanks in advance.
>
>Laura Bellini
>laura_bellini_at_compaq.com
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Thu Jan 15 1998 - 00:00:00 CST

Original text of this message

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