Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> URGENT SQL ( Dynamic table name)

URGENT SQL ( Dynamic table name)

From: Bunyamin K.Karadeniz <bunyamink_at_havelsan.com.tr>
Date: Thu, 25 Jan 2001 16:19:41 +0200
Message-Id: <10752.127475@fatcity.com>


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>&nbsp;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>&nbsp;</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&nbsp;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>&nbsp;</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>&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;But it does not work How can I =
give=20
table_names , table_column_names dynamic. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Can you Give an example =
??</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>
Received on Thu Jan 25 2001 - 08:19:41 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US