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 -> Multi-table inserts and Oracle records

Multi-table inserts and Oracle records

From: Dereck L. Dietz <dietzdl_at_ameritech.net>
Date: Sun, 15 Apr 2007 23:22:46 GMT
Message-ID: <atyUh.16958$Um6.11545@newssvr12.news.prodigy.net>


While reading "Oracle PL/SQL Programming" I came across the section on RECORDs being able to be
used for DML operations such as INSERT and UPDATE.

I easily understand the example(s) given for the single table INSERT and UPDATE but could not find
an example for a multi-table insert and was wondering if a multi-table insert such as:

INSERT FIRST   WHEN ( table_code = '1' ) THEN

    INTO table_one
( field_one,

       field_two,
       field_three )
    VALUES

( field_one,
field_two, field_three )

  WHEN ( table_code = '2' ) THEN

    INTO table_two
( field_one,

       field_two,
       field_three )
    VALUES

( field_one,
field_two, field_three ) SELECT field_one AS field_one, field_two AS field_two, field_three AS field_three

  FROM source_table;

Could possibly be re-written as something like:

INSERT FIRST   WHEN ( table_code = '1' ) THEN

    INTO table_one VALUES field_rec

  WHEN ( table_code = '2' ) THEN

    INTO table_two VALUES field_rec

SELECT field_one AS field_one,
       field_two        AS field_two,
       field_three AS field_three

  FROM source_table; Received on Sun Apr 15 2007 - 18:22:46 CDT

Original text of this message

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