-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3rc2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEdzvXnTTdvBpPNwsRAlinAKD0v8KRhcIpYkrYpyDQV9J9fTYh2wCfaC/t
BjzbDthClLZ3Coq71xjbcfg=
=RRHI
-----END PGP SIGNATURE-----


-------------------------------------------------------
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

Reply via email to