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

Home -> Community -> Usenet -> c.d.o.server -> Re: stupid newbie question

Re: stupid newbie question

From: Jesper Søndergaard <jsoender_at_dk.oracle.com>
Date: Wed, 16 Dec 1998 14:12:50 +0100
Message-ID: <3677B1D1.5FF3E8F@dk.oracle.com>


Hi Kent,

A way to deal with your problem is to use a cursor-loop, like:

declare
  cursor my_cursor is select empno from emp; begin
  for my_rec in my_cursor loop
    ...
    /* Refer to the columns in the query with my_rec.<column_name>, e.g.: */

    update some_table
    set some_column = my_rec.empno
    where <some condition>;
    ...
  end loop;
end;

Use a cursor-loop and you don't have to think about opening, fetching, closing,
and ORA-1403. Furthermore you don't need to declare variables to fetch into.

Cheers,
Jesper

Kent Eilers wrote:

> I writing some PL/SQL procedures and functions and have come up against
> a problem whenever a query returns no rows (ala the ORA-01403: no data
> found error message). I've looked in three books to get a strategy on
> dealing with this and have come up with zilch.
>
> Basically I do not want to go to an exception handler when this
> happens. I thought I had escaped this drainhole by first running a
> query to dump the count(*) into a local variable. But this still
> triggers the 1403 error.
>
> What do all you PL/SQL pro's do? My (rather limited) understanding of
> the exception handler is you cannot 'on error resume....' so how do deal
> with this?
>
> Any response greatly appreciated!
Received on Wed Dec 16 1998 - 07:12:50 CST

Original text of this message

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