I'll see if we can come up with something better, that is, more general to be used in Connection_lastRowId() for postgres, since this method works fine for mysql and sqlite it should so for postgres as well. If you should come over anything for postgres also, please let me know as well.
On 29. feb.. 2008, at 09.35, Paul J Stevens wrote:
Jan-Henrik Haukeland wrote:
What command did you use in dbmail to get last insert row id in postgres?
Well, until now we were using a sequence and called "select curval('sequence_identifier')" after each insert if a last inserted row id was required.
But I've decided to switch to using the 'RETURNING id' instead to avoid the additional roundtrip for the extra query. I use executeQuery for the INSERTs involved, passing the connector and result pointer to my facade for lastRowId. That call then tries to retrieve the id from the resultset if lastRowId returns 0 and the resultset is not null. Appears to work just fine.
Of course 'RETURNING x' is a postgresql construct but I have a framework in place for dealing with backend specific dialect fragments.
On 28. feb.. 2008, at 21.55, Paul J Stevens wrote:
Jan-Henrik,
This call always returns 0 on a postgresql connection. I assume this is because my tables are without OIDs. Is that intentional? I can work around it. But perhaps a small note in the api docs would be in order?