Re: Dynamic SQL

From: Jason Wells <jason.wells_at_tapestry.com>
Date: 1996/05/11
Message-ID: <3194B1A6.7B44_at_tapestry.com>#1/1


Aravind,B.R. wrote:
>
> -How to use dynamic SQL in oracle?
> -Is it possible to create SQL query from a string with proper
> SQL syntax?

Yes. For instance, let's say you wanted to create the SQL query:

select * from emp;

You could do it something like this:

select 'select * from emp' from dual;

Of course, that's an extremely simple and worthless example. But you get the idea. If you wanted to, you could drop all of the tables owned by the user 'BOB' with something like this:

select	'drop table ' || table_name || ';' 
from	dba_tables
where	owner = 'BOB';

then you capture the output of this statement into a SQL*Plus spool file.

Hope this helps you out.

-- 
==============================================================================
Jason Wells                 Tapestry Computing, Inc.       Voice: 314.344.0066
Senior Software Developer   Email:jason.wells_at_tapestry.com   Fax: 314.344.0990
==============================================================================
Received on Sat May 11 1996 - 00:00:00 CEST

Original text of this message