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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Dynamic table and column identifiers?

Re: Dynamic table and column identifiers?

From: -=< a q u a b u b b l e >=- <aquabubble_at_Remove.No.Parma.Ham.Remove.geocities.com>
Date: Fri, 29 Oct 1999 00:47:29 +0100
Message-ID: <7vcnlh$7c0$1@news4.svr.pol.co.uk>


dd <dd.ss_at_ss.no> wrote in message
news:BS3S3.14790$7G2.96247_at_news1.online.no...
> I want to
>
> select count(*)
> from {all tables that have a column named my_special_column}
> where {the table's owner}=my_special_user

Using dynamic SQL, use a cursor to select table names... i.e.

CURSOR my_special_cur IS
SELECT table_name, column_name, owner
  FROM all_tab_columns
 WHERE column_name = 'MY_SPECIAL_COLUMN';

...then build up a string which you would parse and execute using DBMS_SQL.

> Also, I would like to
>
> select {n first columns}
> from {all tables that have a column named my_special_column}
> where {the table's owner}=my_special_user
> and my_special_column='my_special_value'

Similarly to above.

Using
> Can somebody please rewrite pseudo-parts into SQL or show me another way
to
> achieve this?
>
> Regards Dag
>
> STARTADDRESSdpedeATonlineDOTnoENDADDRESS
Received on Thu Oct 28 1999 - 18:47:29 CDT

Original text of this message

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