EDIT: The previously recommended solution only works for MSSQL. Therefore, I am adding an Oracle solution. I keep the original answer below.
I thought of another solution (although the one provided by Justin Cave still seems a little better) using temporary tables.
Here's how it might look like
CREATE GLOBAL TEMPORARY TABLE temp_ids (id INT) ON COMMIT PRESERVE ROWS; INSERT INTO ids (id) VALUES (101); INSERT INTO ids (id) VALUES (102); INSERT INTO ids (id) VALUES (103);
This should be a valid solution for an Oracle database.
Original answer below
I ran into a similar problem, and here is my solution (this does not work in Oracle DB, as mentioned in the comments, only MSSQL)
WITH cte AS ( SELECT * FROM ( VALUES (1, 2, 3, ...), (2, 3, 4, ...) ) AS a (col1, col2, col3, ...) ) INSERT INTO ...
Hope this helps :)
Zax
source share