Unix Technical Forum

How to create a dynamic cursor?

This is a discussion on How to create a dynamic cursor? within the Oracle Database forums, part of the Database Server Software category; --> How do i do a dynamic cursor? I know how to use Execute Immediate and do a select into, ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 06:24 PM
Ryan Gaffuri
 
Posts: n/a
Default How to create a dynamic cursor?

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-22-2008, 06:24 PM
Ryan Gaffuri
 
Posts: n/a
Default Re: How to create a dynamic cursor?

DA Morgan <damorgan@exesolutions.com> wrote in message news:<3E149FA0.CB96646B@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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-22-2008, 06:24 PM
Ryan Gaffuri
 
Posts: n/a
Default Re: How to create a dynamic cursor?

DA Morgan <damorgan@exesolutions.com> wrote in message news:<3E149FA0.CB96646B@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


Sorry to have bothered you. I found my metalink account and dug it up
there. Sorry, couldnt find my login so asked here. I used a REF cursor
to do it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com