Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: generating SQL in SQL
I always do it as follows :
select 'select '||''''||table_name||''''||', count(*) from
'||table_name||';'
from all_tables
where table_name = 'foo';
Scott Freeman wrote:
>
> I am trying to generate SQL select statements dynamically through a
> select. What I have is:
>
> select "select """||table_name||""", count(*) from "||table_name||";"
> from all_tables
> where table_name = 'foo';
>
> The statement I am trying to get out of this is:
>
> select "foo", count(*) from foo;
>
> I get the following error...
>
> select "select """||table_name||""", count(*) from "||table_name||";"
> *
> ORA-00904: invalid column name
>
> Help with this would be appreciated.
>
> Scott
>
> --
> Scott E. Freeman
> freeman_at_cs.purdue.edu
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Oct 27 1999 - 12:54:57 CDT
![]() |
![]() |