简体   繁体   中英

inserting into table oracle

I have created table that consists of only foreign keys, it created successfully, but now I am inserting into the table and getting an error. ALL my tables before created successfully and works fine.

This is my code:

insert ALL 
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7113', '8115')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('511', 'null', '7111', '8111')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7111', '8114')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('514', 'ret001', '7113', '8113')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('516', 'null', '7115', '8112')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('515', 'ret002', '7114', '8113')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('517', 'null', '7113', '8115')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('511', 'null', '7112', '8118')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('513', 'null', '7111', '8117')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7115', '8116')
select * from DUAL;
select * from PRODUCT_BILLING;

This is my error:

Error starting at line : 147 in command -
insert ALL 
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7113', '8115')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('511', 'null', '7111', '8111')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7111', '8114')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('514', 'ret001', '7113', '8113')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('516', 'null', '7115', '8112')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('515', 'ret002', '7114', '8113')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('517', 'null', '7113', '8115')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('511', 'null', '7112', '8118')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('513', 'null', '7111', '8117')
    INTO PRODUCT_BILLING (DeliveryID, ReturnID, ProductID, BillID) VALUES
('512', 'null', '7115', '8116')
select * from DUAL
Error report -
ORA-02291: integrity constraint (SYSTEM.SYS_C008513) violated - parent key not found

>>Query Run In:Query Result 6

I would speculate that the problem is 'null' . That seems like a very unusual value for a key.

If you want NULL , drop the single quotes.

I am guessing that the other values are also numbers -- they certainly look like numbers. You should drop the single quotes for them too:

VALUES (512, null, 7113, 8115)

Of course, keep the single quotes if the values are really strings. But only use single quotes for string and date constants.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM