In Oracle, one can insert multiple rows by doing a query like
INSERT ALL
INTO mytable (column1, column2, column3) VALUES ('val1.1', 'val1.2', 'val1.3')
INTO mytable (column1, column2, column3) VALUES ('val2.1', 'val2.2', 'val2.3')
INTO mytable (column1, column2, column3) VALUES ('val3.1', 'val3.2', 'val3.3')
SELECT * FROM dual;
And with a prepared statement, doing a single insert like this one
BEGIN INSERT
INTO mytable (column1, column2, column3) VALUES (null, 'val1.2', 'val1.3')
RETURNING column1 INTO ?; END;
will result in returning column1
's value (supposing there is a trigger assigning a value to it before insert).
Is there a way, if possible at all, to combine both? Meaning, inserting multiple values while still returning all the column1
values (a resultset) with a single query?
From the documentation (at least through the 21c version), one of the restrictions to the returning clause:
You cannot specify the returning_clause for a multitable insert.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With