Originally posted by jesse harris: anyone know a good way to return the identity of a row that was just inserted?
Another idea that works with oracle(it may be possible in SQLServer too) is to use a select statement to obtain the new identifier. In Oracle the database will give out the next available id (as if it were in an insert statement) then use the id in your insert statement. Oracle code: resultset = statement.executeQuery("select sequence.nextVal from dual"); long nextId = resultset.getLong(1); --> this selects the next id value from the database. dual is just a dummy table so you can accomplish the select statement. statement.executeUpdate("insert into table (id, name) values (" + nextId + ", 'Joey Joe Joe Shabadoo')"); Jamie
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads