Hi, Have you looked at the sequence API included in libdbi?
unsigned long long dbi_conn_sequence_next(dbi_conn Conn, const char *name); and unsigned long long dbi_conn_sequence_last(dbi_conn Conn, const char *name); Regards, Christian On Friday 26 May 2006 19:33, Andrew Sidwell wrote: > Hi, > > In a project I recently wrote, I had a situation where I had a table > where the primary key was auto-incrementing, and whenever I inserted > something into it, I wanted its ID so I could reference it from another > table, e.g.: > > CREATE TABLE customer ( id SERIAL PRIMARY KEY, name TEXT ); > CREATE TABLE order ( id SERIAL PRIMARY KEY, price FLOAT, customer INTEGER > ); > > INSERT INTO customer VALUES ( NULL, "Stuart" ); > INSERT INTO order VALUES ( NULL, 34.00, id_of_stuart ); > > 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. > > I'd be happy to contribute code for the PGSQL driver, if an API was > defined. > > Andrew Sidwell > > > > ------------------------------------------------------- > 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 ------------------------------------------------------- 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