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: How to create a dynamic cursor?

Re: How to create a dynamic cursor?

From: Ryan Gaffuri <rgaffuri_at_cox.net>
Date: 3 Jan 2003 03:50:38 -0800
Message-ID: <1efdad5b.0301030350.528670dd@posting.google.com>


DA Morgan <damorgan_at_exesolutions.com> wrote in message news:<3E149FA0.CB96646B_at_exesolutions.com>...
> Ryan Gaffuri wrote:
>
> > How do i do a dynamic cursor? I know how to use Execute Immediate and
> > do a select into, but how do I do it with an explicit cursor?
> >
> > Also, anyone know which book explains it? Checked the Fuerstein book
> > and the OTN PL/SQL doc and couldnt find it.
> >
> > Could I do it with a REF cursor?
>
> I've no doubt you are confused as your posting is confusing to me.
>
> Rather than throwing around dynamic/explicit/ref cursor ... why not just
> tell us what you are trying to do.
>
> It would make it much easier to help you.
>
> Daniel Morgan

Not sure how else to explain. I do not know what table or my column names until run time. I have to pass in variables.

For example

Execute Immediate 'Select :1 ' ||

                  ' From :2 ';
                  using foo, foo1
                  into var1, var2;

This is a dynamic implicit cursor.

I need to do an explicit version of it.

declare
CURSOR cur_cursor is

    ' Select :1 ' ||
    ' From :2 ';

open cur_cursor;

   loop

     fetch cur_cursor
      into rec_cursor;
      exit when cur_cursor%notfound;

    end loop;

how do i do that? Where is the documentation on this? Can I do this kind of thing with a REF cursor and without using DBMS_SQL?

This is just pseudo-code, so dont worry about the minor syntax errors. Received on Fri Jan 03 2003 - 05:50:38 CST

Original text of this message

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