Re: SQL select into

From: Günther Venier <gvenier_at_gosch.com>
Date: Thu, 28 Sep 2000 09:46:58 +0100
Message-ID: <39D30582.3DBA4F80_at_gosch.com>


Hi, Greg!

An even better way to do this is recommended by Steven Feuerstein in his book "Oracle PL/SQL Programming" by using a cursor (you get rid of the "too_many_rows" problem, too):
e.g. an explicit cursor:
DECLARE CURSOR cur_x IS
  SELECT a, b, c, ...
  FROM table1
  WHERE...;
  rec_x table1%rowtype;
BEGIN
  OPEN cur_x;
  FETCH cur_x INTO rec_x;
  IF cur_x%NOTFOUND THEN
    your_no_data_found_procedure; -- that's the NO_DATA_FOUND section   END IF;
  CLOSE rec_x;
END; If you expect multiple records, you will have to use the CURSOR-FOR-LOOP. Günther

Greg schrieb:

> I have a lot of select into
> query's
>
> If U make a select into and there are no records
>
> U got the error ORA-01403: no data found
>
> so I do first a
>
> select count (....)
> into counter
> ...
>
> if counter = 1 then
> select .....
> into
> .....
> end if;
>
> Now im wondering if there is a better solution then
> the way I do it......sure is.....
>
> like do it all in one step
>
> Thanks Greg
Received on Thu Sep 28 2000 - 10:46:58 CEST

Original text of this message