Getting inserted ID after INSERT ... SELECT on Oracle Getting inserted ID after INSERT ... SELECT on Oracle oracle oracle

Getting inserted ID after INSERT ... SELECT on Oracle


java.sql.Connection.prepareStatement(java.lang.String, int) interface is clear

Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys

So you are using The wrong method. Try

return con.prepareStatement(        "insert into Person (Name) select 'Bob' from dual",        Statement.RETURN_GENERATED_KEYS);

instead


How about

INSERT INTO blah b (blah1, blah2, blah3)VALUES (?, ?, ?) RETURNING b.id INTO ?";


This feature isn't supported by Oracle JDBC Driver