[IGN-5112]Oracle and generated ids

The typical ignition method of getting the generated id by adding getKey=1 to the runPrepQuery call throws a java exception indicating that getInt() is not supported. I modified the driver config to add support for getKey, but it didn't silence the exception. From what I can tell, if I were writing the Java JDBC code myself, I could accomplish getting the id with the following code:

PreparedStatement prepareStatement = connection.prepareStatement("insert...",
        new String[] { "your_primary_key_column_name" });
 
prepareStatement.executeUpdate();
 
ResultSet generatedKeys = prepareStatement.getGeneratedKeys();
if (null != generatedKeys && generatedKeys.next()) {
     Long primaryKey = generatedKeys.getLong(1);
}

Of course, I can completely roll my own java code to accomplish this myself, or maybe write a stored procedure (though I personally loathe putting code into the database, but get it that oracle is using a trigger and a sequence to accomplish this otherwise). Does anyone have any experience with this issue?

The year is 2022, and I am having the same issue here :wink:

We have a bug ticket for this internally, but we also haven't given it a lot of priority (clearly :flushed:) because relatively few of our customers use Oracle, and relatively few of those customers need getKey.

If you'd like it to happen sooner, talking to your sales rep and adding an ideas post are generally the way to go.

1 Like

Oh! I got it, well for me the most important thing is to have this info. Because we always think we are missing something.