posted 20 years ago
From the stacktrace I see you're using Oracle, correct? You can grab the next sequence value using a simple select statement:In Oracle, dual is a special psuedo-table containing a single row allowing for these kinds of tricks.
It also looks like you're using a PreparedStatement. Do you have a ? placeholder for the primary key? If so, you must supply a value. Or, are you registering it as an OUT parameter? If the latter, I'm not aware that Oracle will send it back to you automatically.
In fact, I'm not aware of Oracle having any kind of auto-generated primary key mechanism, though perhaps you can set the default for the column as the sequence's next value. Since my apps have always needed to access the row being inserted after insertion, I always grab the sequence value and then use it in the insert as A. S. Kumar suggested.
[ January 25, 2005: Message edited by: David Harkness ]