You need to use dynamic sql, you will need
to use pl/sql (or any other procedural language) for that. Just Google for “oracle
dynamic sql” and you’ll find many examples
Ken
From:
oracle-l-bounce@freelists.org [mailto:oracle-l-bounce@freelists.org] On Behalf Of iwei16@gmail.com
Sent: Saturday, August 11, 2007
11:34 PM
To: oracle-l@freelists.org
Subject: query help, please
I have the following query:
select table_name, table_name_id, count(*)
from approved_tables
group by table_name, table_name_id
order by count(*) desc
TABLE_NAME
TABLE_NAME_ID
COUNT(*)
---------------- ------------- ------------- -----------
eHA_Cont_P
1153600965418
5254
CSElent
1151606341446
5179
CSElent
1151606341460
5163
eHA_Cont_P
1151606276700
3808
Page
1155140051116
3805
The data in the TABLE_NAME column are the names of tables.
I need to query the data for the TABLE_NAME column using TABLE_NAME_ as
the FK
(for example: select name from eHA_Cont_P where id = 1153600965418;
----
xxx
)
and
need to see the output from the above query with the resulting "NAME"
value.
So I need something like this:
TABLE_NAME
TABLE_NAME_ID
COUNT(*) NAME
---------------- ------------- -------------
-------------------------------------------
eHA_Cont_P 1153600965418
5254 XXX
CSElent
1151606341446
5179 YYY
CSElent
1151606341460
5163 ZZZ
eHA_Cont_P
1151606276700
3808 WWW
Page
1155140051116
3805 VVVV
How would I do that?
Please help.
Thanks.