dbi_classic_question_about_getting_rowids

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: dbi-users@perl.org
From: altair@rhythm.cx
Subject: Getting IDs back after INSERTs
Date: Wed, 14 Feb 2001 19:13:18 -0500 (EST)

How do I get the ID used after an INSERT into a table that has an
auto-assign primary ID column? I've been search all over for the answer but
I could not find it in any FAQs for anything. I'm using I'm using the
DBD::ODBC driver.

Thanks

===

To: altair@rhythm.cx
From: Michael Peppler <mpeppler@peppler.org>
Subject: Re: Getting IDs back after INSERTs
Date: Wed, 14 Feb 2001 16:33:52 -0800 (PST)

altair@rhythm.cx writes:
 > 
 > How do I get the ID used after an INSERT into a table that has an
 > auto-assign primary ID column? I've been search all over for the answer but
 > I could not find it in any FAQs for anything. I'm using I'm using the
 > DBD::ODBC driver.

Depends.

If it's Sybase or MS-SQL you need to do

select @@identity

after the insert.

===

To: <altair@rhythm.cx>, <dbi-users@perl.org>
From: "Mark Zimmerman" <zimm@rcn.com>
Subject: Re: Getting IDs back after INSERTs
Date: Wed, 14 Feb 2001 19:34:16 -0500

a really sleazy way would be to select 1 row from the table right after the
update and order it by descending id
:)

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu