Re: CURSOR

From: Forrest Cicogni <fcicogni_at_sageasset.com>
Date: Sat, 1 Dec 2001 11:25:01 -0500
Message-ID: <1007209783.603543_at_news>


Two ways:

1st - Define a weakly typed REF cursor



declare
    type       my_cur     IS REF CURSOR ;
    cursor    my_cv      my_cur;

begin

    open my_cv for select * from emp where emp_no = 2222; end;

2nd - Define a strongly typed REF cursor



declare
    type       my_cur     IS REF CURSOR RETURN    emp%rowtype;
    cursor    my_cv      my_cur;

begin

    open my_cv for select * from emp where emp_no = 2222; end;

Keep in mind that if you are returning the cursor as a result set, the cursor type needs to be defined at the package level and specified as an IN OUT parameter. Strongly typed cursor variables are always preferred;

"Allan Martin" <allan.martin_at_saic.com> wrote in message news:3c0855e2_at_cpns1.saic.com...
> Hi,
>
> I'm trying to write a cursor which has a where clause in it. However, the
> where condition is not discovered until later in the script. How do I make
> the cursor only compile after the select has taken place that finds the
> condition. I don't want to store this as a stored procedure, I just need
it
> as a sql script.
>
> Thanks in advance.
>
> Allan Martin
>
>
Received on Sat Dec 01 2001 - 17:25:01 CET

Original text of this message