I already found out about the INSERT ALL syntax and it works fine as long I don't want to retrieve the inserted id values.
As an opposite to INSERT ALL syntax I could just use mutliple INSERT INTO statements in a transaction which would work but is bad for performance as stated here: Best way to do multi-row insert in Oracle?.
This is my current code:
//Creation of INSERT INTO statement
//...
Statement statement = dbConnection.createStatement();
statement.executeUpdate(INSERT_SQL, new String[] {"someIDColumn"});
ResultSet idResulSet = statement.getGeneratedKeys();
//Usage of the generated keys
It works for a single row but if I try the INSERT ALL syntax I get an:
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
Caused by: Error : 933, Position : 187, Sql = INSERT ALL INTO bpos(artnr, bstnr, menge) VALUES (3, 31, 4) INTO bpos(artnr, bstnr, menge) VALUES (5, 31, 6) INTO bpos(artnr, bstnr, menge) VALUES (1, 31, 2) SELECT * FROM dual RETURNING artnr INTO :1 , OriginalSql = INSERT ALL INTO bpos(artnr, bstnr, menge) VALUES (3, 31, 4) INTO bpos(artnr, bstnr, menge) VALUES (5, 31, 6) INTO bpos(artnr, bstnr, menge) VALUES (1, 31, 2) SELECT * FROM dual RETURNING artnr INTO ?, Error Msg = ORA-00933: SQL command not properly ended
Is it possible to retrieve all inserted ids after an INSERT ALL statement?