Limitations for multi-user inserts include:
- You cannot specify a sequence in any part of a multiple insertion. Multiple insertion is considered as a single SQL statement. Therefore, the first reference to NEXTVAL generates the next number, and all subsequent links in the statement return the same number.
This is not entirely true: you can use a sequence, it always gets the same value, so it can be useful to create parent and child records at a time by accessing the same sequence.
If you want to continue using insert all , you can get around this using a non-deterministic function that gets the value of the sequence:
CREATE FUNCTION get_seq RETURN NUMBER IS BEGIN RETURN postal_code_seq.nextval; END; / INSERT ALL INTO POSTAL_CODE( postal_code,description) VALUES(get_seq,'Coimbatore') INTO POSTAL_CODE (postal_code,description) VALUES(get_seq,'Mumbai') SELECT * FROM DUAL; 2 rows inserted. SELECT * FROM postal_code; POSTAL_CODE DESCRIPTION
But this is a little inconvenient. You are probably better off using separate insertion instructions — using multi-user insertion into the same table doesn’t really greatly increase you — or a trigger to set a unique column from a sequence or a CTE / inline view to generate values for insertion.
source share