use tablename in variable [message #371770] |
Mon, 04 December 2000 09:21 |
Sameer
Messages: 60 Registered: March 1998
|
Member |
|
|
i wish to dynamically use the tables in my database
ie. if user should want to query any table it can be done thru a variable that holds id to the table name
eg. if user wishes to work in 'xyz' company
he can select 'xyz' from lov and internally query can be done on the table with name 'table_xyz'
|
|
|
Re: use tablename in variable [message #371785 is a reply to message #371770] |
Tue, 05 December 2000 16:25 |
Madhav Kasojjala
Messages: 42 Registered: November 2000
|
Member |
|
|
Hi Sameer,
If you are using oracle 8i,
you can use execute immediate to feed dynamic sql
if 7.x use DBMS-SQL package to develop dyn.sql.
1st one is easy like this.
function(vTableName in varchar2)
return number
is
vCnt Number;
begin
execute immediate
(' select count(*) into '||vCnt||' from '||vTableName);
return vCnt;
end;
Lemme know if u have problems
Madhav
|
|
|