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: Noel <tbal_at_go2.pl>
Date: Fri, 2 Apr 2004 17:50:41 +0100
Message-ID: <c4k1s0$93j$1@inews.gazeta.pl>

> > > >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
Received on Fri Apr 02 2004 - 10:50:41 CST

Original text of this message

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