By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,501 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,501 IT Pros & Developers. It's quick & easy.

dynamic tablename with %rowtype

P: n/a
Sri
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ko******@hotmail.com (Sri) wrote in message news:<3f**************************@posting.google. com>...
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

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
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.