Hi Jens, First of all it depends on the database what excact procure is required for identity mangement.
However the DBRecord class will handle the differences an should behave the same way no matter what database driver is used. If you use a DBCommand however, you will need to consider what is needed to retrieve the autoinc key. The code that does all the handling for a DBRecord can be found in DBRowSet.updateRecord(...) This method generates an insert statement using a DBCommand and shows when and how to use DBSetGenKey. But usually its best to simply use a DBRecord. You did not say why the DBRecord did not work for you. If you look at our examples, they all create records using a DBRecord and obtain the key. Please make sure, that the column is declared da DataType.AUTOINC otherwise no identity mangement is performed at all. And plase let us know what Database or driver repectively you are using. Regards Rainer > from: Jens Breitenstein [mailto:[email protected]] > to: [email protected] > re: retrieve id of auto-inc field after insert > > hi all! > > I need to retrieve the auto-inc key after an insert. I found a class > called DBDatabaseDriver.DBSetGenKeys which seems to be perfect, but > unfortunately this is only accessible via DBDatabase. As the comment > states it's not recommended to use this method but DBCommand. > Unfortunately DBCommand does not support beans (as far as I saw from > the > source) so I tried DBRecord which does not support DBSetGenKeys. So I > am > running in circles I guess. > > Is there an easy solution to create a DBCommand using values from a > bean? Or to retrieve the auto-inc value from the inserted DBRecord? > > > Thanks in advance > > Jens
