Re: [Pride-users] LAST_INSERT_ID in mysql or access to select @@identity
Brought to you by:
jlessner
|
From: <jle...@gm...> - 2005-04-22 20:50:25
|
Peter, Although there is currently no support for that in PriDE it may be interesting to know that this is an issue of on-going development. I recently got a contribution with the required code extensions for that feature and we are planning to incorporate the changes in the next weeks. So the next release in May will have that inside. Until that day, you could add your own extension pretty quickly: - extend function Database.sqlUpdate to get passed an array of auto-fields from function Database.createRecord - in Database.sqlUpdate, call Statement.executeUpdate(String <cid:par...@gm...> sql, String <cid:par...@gm...>[] columnNames) rather than executeUpdate(String sql), passing the array of auto-fields as second parameter - call Statement.getAutoGeneratedKeys() after successful SQL execution - return the ResultSet from getAutoGeneratedKeys to Database.createRecord - add a function RecordDescriptor.record2object which gets passed the ResultSet, the target object and the auto field array to extract these field's values from the result set. This is how the code will look like in the extended version. It takes some knowledge about PriDE's source of course but it will probably don't take more then 20 lines of code :-) Regards, Jan Peter Girard schrieb: > Is there a way to get the id of the last inserted record, if the > record has an auto increment column? > > thanks |