Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

INSERT ALL no working

muttleychessMay 30 2017 — edited Jun 28 2017

Hi

   I saw a exmple in

edited: http://www.oraclefrontovik.com/2016/02/using-insert-all-with-related-tables/

but I tried to execute in my computer, and no work

CREATE TABLE parent_tbl (the_pkNUMBER PRIMARY KEY,
object_id NUMBER);

  CREATE TABLE child_tbl (the_pk  NUMBER PRIMARY KEY,
the_fk  NUMBER,
object_name VARCHAR2(30));

ALTER TABLE child_tbl

    ADD CONSTRAINT child_tbl_fk1 FOREIGN KEY (the_fk)

    CREATE SEQUENCE parent_tbl_seq;

    CREATE SEQUENCE child_tbl_seq START WITH 500;                    

 

 

    INSERT ALL

    INTO parent_tbl(the_pk, object_id)

    VALUES (parent_tbl_seq.nextval,

object_id)

    INTO child_tbl(the_pk, the_fk, object_name)

    VALUES (child_tbl_seq.nextval,

parent_tbl_seq.currval,
object_name)

    SELECT uo.object_id,

uo.object_name

    FROM user_objects uo;

show me error:

ORA-02291: restrição de integridade myowner.CHILD_TBL_FK1) violada - chave mãe não localizada

This post has been answered by Paulzip on May 30 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2017
Added on May 30 2017
6 comments
366 views