Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> URGENT SQL ( Dynamic table name)
This is a multi-part message in MIME format.
------=_NextPart_000_02CA_01C086EA.9EE57140 Content-Type: text/plain;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable
I have to write a script to query all the tables of a user. So I have = to give the table_name as variable.
I wrote ....
Declare
Cursor c1 is Select table_name from user_tables;
c1row c1%rowtype;
BEGIN
For c1row in c1 LOOP
Select count(*) from c1row.TABLE_NAME;
.....
END LOOP;
END;
But it does not work How can I give table_names , table_column_names =
dynamic.=20
Can you Give an example ??
------=_NextPart_000_02CA_01C086EA.9EE57140 Content-Type: text/html;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-9" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2> I have to write a script to query =
all the=20
tables of a user. So I have to give the table_name as =
variable.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I wrote ....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Declare</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Cursor c1 is Select table_name =
from=20
user_tables;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>c1row c1%rowtype;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>BEGIN</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For c1row in c1 LOOP</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Select count(*) from=20
c1row.TABLE_NAME;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>END LOOP;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>END;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2> But it does not work How can I =
give=20
table_names , table_column_names dynamic. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> Can you Give an example =
??</FONT></DIV>
<DIV> </DIV></BODY></HTML>
Received on Thu Jan 25 2001 - 08:19:41 CST
![]() |
![]() |