Andrew Sidwell writes: > I couldn't see any interface to selecting back the row that was just > inserted, even though PostgreSQL (and I believe most other DBs) support > some method of doing this. In the end I had to write a nasty hack in > the PGSQL driver just for my project, but it'd be nice if this had an > API within libdbi and was supported by all DB drivers that could do so. >
libdbi has the following function for this purpose: unsigned long long dbi_conn_sequence_last(dbi_conn Conn, const char *name); Requests the row ID generated by the last INSERT command. The row ID is most commonly generated by an auto-incrementing column in the table. Use the return value to address the dataset that was last inserted. Arguments Conn: The current database connection. name: The name of the sequence, or NULL if the database engine does not use explicit sequences. Note: You may have noted that this function does not sufficiently encapsulate the peculiarities of the underlying database engines. You must keep track of sequence names yourself if your target database engine does use sequences. Returns An integer value corresponding to the ID that was created by the last INSERT command. Hope this helps Markus -- Markus Hoenicka [EMAIL PROTECTED] (Spam-protected email: replace the quadrupeds with "mhoenicka") http://www.mhoenicka.de ------------------------------------------------------- All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 _______________________________________________ libdbi-users mailing list libdbi-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libdbi-users