Re: Strange cursor behavior?
Date: Tue, 24 Dec 2002 12:00:33 GMT
Message-ID: <B%XN9.54673$pe.1976266_at_news2.east.cox.net>
Is this what you tried?
declare
c pkg.c_type;
c_rec dual%rowtype;
begin
open c for 'select dummy from dual';
loop
fetch c into c_rec;
exit when c%notfound;
dbms_output.put_line('c is ' || c_rec.dummy);
end loop;
close c;
end;
"Vasileios Lourdas" <Vasileios.Lourdas_at_eurodyn.com> wrote in message
news:3E080C70.62AB667C_at_eurodyn.com...
> Hi,
>
> Still same results (tested in 8.1.6).
>
> Any insights?
>
>
> Brian E Dick wrote:
> >
> > Check for "not found" after the fetch.
> >
> > "Vasileios Lourdas" <lourdas_at_otenet.gr> wrote in message
> > news:au7slq$9id$1_at_nic.grnet.gr...
> > > Hello,
> > >
> > > When executing this PL/SQL code snippet in Oracle 8.1.6 and Oracle
9.0.1:
> > > ***
> > > declare
> > > c pkg.c_type;
> > > c_rec dual%rowtype;
> > >
> > > begin
> > > open c for 'select dummy from dual';
> > > loop
> > > exit when c%notfound;
> > > fetch c into c_rec;
> > > dbms_output.put_line('c is ' || c_rec.dummy);
> > > end loop;
> > > close c;
> > > end;
> > > ***
> > > i get the following results:
> > > ***
> > > SQL> /
> > > c is X
> > > c is X
> > >
> > > PL/SQL procedure successfully completed
> > >
> > > SQL>
> > > ***
> > > c_type is a type of a ref cursor declared in a package spec pkg.
However,
> > > since the DUAL table has only one row, why the loop executes twice
before
it
> > > ends?
> > >
> > > I'm sorry if i miss something obvious, but this came across today and
i've
> > > been thinking about it...
> > >
> > > Thanks,
> > > Vasilis
> > >
> > >
Received on Tue Dec 24 2002 - 13:00:33 CET