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

Home -> Community -> Usenet -> c.d.o.server -> Re: Resemble script for Oracle database

Re: Resemble script for Oracle database

From: Daniel Morgan <damorgan_at_x.washington.edu>
Date: Fri, 02 Apr 2004 18:52:48 -0800
Message-ID: <1080960748.914585@yasure>


Noel wrote:

>>>>>Hi,
>>>>>SELECT * INTO ABC FROM XYZ
>>>>
>>>>Refer to 'CREATE TABLE .... AS SELECT'
>>>
>>>also refer to 'INSERT INTO TABLE SELECT * FROM OTHERTABLE'.
>>
>>That does not create the table and presumes the table already exists.
>>
>>I don't think there's a way in oracle to create the table if it does not
>>exists. You either create the table OR insert in it.

>
>
> DECLARE
> table_exists BOOLEAN;
> BEGIN
> table_exists := FALSE;
> BEGIN
> EXECUTE IMMEDIATE 'CREATE TABLE XXX AS SELECT * FROM USER_TABLES';
> EXCEPTION WHEN OTHERS THEN
> table_exists := TRUE;
> END;
>
> IF table_exists THEN
> EXECUTE IMMEDIATE 'INSERT INTO XXX SELECT * FROM USER_TABLES';
> END IF;
> END;
>
> --
> TomekB

And what was the point of showing how to do something that you should never ever do in Oracle? Seems sort of like teaching children to jump in front of moving cars.

-- 
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Fri Apr 02 2004 - 20:52:48 CST

Original text of this message

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