Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to create a dynamic cursor?
How would the pl/sql compiler know what to do at compile time? Answer: it
can't so you can't have a static dynamic cursor. It can't check a table
name and data types for the column if those things are not defined ahead of
time.
One thing you can do is create a bunch of cursors and use the one that matches. Are there that many combinations of tables and columns? Have an if or case statement and pass in the variables and return the cursor that matches the table column name combination. Jim
-- Replace part of the email address: kennedy-down_with_spammers_at_attbi.com with family. Remove the negative part, keep the minus sign. You can figure it out. "Ryan Gaffuri" <rgaffuri_at_cox.net> wrote in message news:1efdad5b.0301030350.528670dd_at_posting.google.com...Received on Fri Jan 03 2003 - 10:29:58 CST
> 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.
![]() |
![]() |