Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 10:46 PM
Sri
Guest
 
Posts: n/a
Default dynamic tablename with %rowtype

how to handle a situation where i wnt a variable of type ref cursor.

TYPE refCur IS REF CURSOR;
rc refCur;

myRow rc%rowtype; -- How can I make this work???

The whole problem is that only on run time I am able to know the table
on which i have to work. So I have created a Ref Cursor

BEGIN
sqlStmt := 'select * from ' || mytable; -- mytable is stored in one
of the table in the database. depending on the parameter passed to
the proc the table name is retrived.

OPEN rc FOR sqlStmt;
LOOP
FETCH rc into myRow; -- ??? I want to fetch the data from the
cursor in a rowtype of the table - mytable. how to handle this
situation.
....
....
END LOOP;
END;

please guide me... as to how can i make a variable of my cursor
rowtype. i am in urgent need of a solution asap.
thanks

Sri
  #2  
Old July 19th, 2005, 10:46 PM
Dave
Guest
 
Posts: n/a
Default Re: dynamic tablename with %rowtype

kool_sri@hotmail.com (Sri) wrote in message news:<3f2140c3.0404122119.780e062d@posting.google. com>...[color=blue]
> how to handle a situation where i wnt a variable of type ref cursor.
>
> TYPE refCur IS REF CURSOR;
> rc refCur;
>
> myRow rc%rowtype; -- How can I make this work???
>
> The whole problem is that only on run time I am able to know the table
> on which i have to work. So I have created a Ref Cursor
>
> BEGIN
> sqlStmt := 'select * from ' || mytable; -- mytable is stored in one
> of the table in the database. depending on the parameter passed to
> the proc the table name is retrived.
>
> OPEN rc FOR sqlStmt;
> LOOP
> FETCH rc into myRow; -- ??? I want to fetch the data from the
> cursor in a rowtype of the table - mytable. how to handle this
> situation.
> ....
> ....
> END LOOP;
> END;
>
> please guide me... as to how can i make a variable of my cursor
> rowtype. i am in urgent need of a solution asap.
> thanks
>
> Sri[/color]


I don't think you can do this dynamically with straight PL/SQL code.
But take a look at the Oracle supplied package DBMS_SQL. It may allow
you to do this, or accomplish the same thing in a different way.

Dave
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles