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: dynamically query mutiple tables

Re: dynamically query mutiple tables

From: Walt <walt_askier_at_SHOESyahoo.com>
Date: Tue, 13 Feb 2007 10:56:15 -0500
Message-ID: <12t3nt0ri3g3rb8@corp.supernews.com>


Peter Parker wrote:
> Is it possible to use pl/sql script to dynamically query all the tables
> owned by a user with a select statement and flag the query that yield
> result? For example, I like to apply the following statement:
>
> select * from [table_name] where id = 'some_id'
>
> to all tables and out put the table_name(s) that satisfies the query. Please
> help. Thanks

Yes, it's possible. Start with "select table_name from user_tables", loop through the result set, build up a dynamic SQL query for each table and run it. Be sure to handle exceptions, because the chance of every table having a field called "id" is rather small.

Not really recomended, but it's possible.

//Walt Received on Tue Feb 13 2007 - 09:56:15 CST

Original text of this message

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