Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: CURSOR
Two ways:
1st - Define a weakly typed REF cursor
type my_cur IS REF CURSOR ; cursor my_cv my_cur;
open my_cv for select * from emp where emp_no = 2222; end;
2nd - Define a strongly typed REF cursor
type my_cur IS REF CURSOR RETURN emp%rowtype; cursor my_cv my_cur;
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 - 10:25:01 CST