That's it!

That returns my primary key, thanks Michael!

PS> One caveat, ya have to make sure you escape those @ signs.  Like this...

        $sth = $dbh->prepare( "select \@\@identity");
        $sth->execute();

____________________
Chris Spurgeon
Senior Design Technologist
[EMAIL PROTECTED]

ELECTRONIC INK
One South Broad Street
19th Floor
Philadelphia, PA 19107
www.electronicink.com

t 215.922.3800 x(233)
f 215.922.3880


-----Original Message-----
From: Michael Peppler [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, November 20, 2001 5:21 PM
To: Chris Spurgeon
Cc: '[EMAIL PROTECTED]'
Subject: Re: Checking result of MS Access insert statement


Chris Spurgeon wrote:
> 
> I'm using DBI:ODBC to talk with a Microsoft Acces database and things are
> going along swimmingly, but I have this one issue...
> 
> I can perform an INSERT statement successfully.  Immediately after I do
the
> INSERT, this line...
> 
>      my $rowcount = $sth->rows;
> 
> ....returns a value of 1, indicating a successful operation.  But I was
also
> hoping that this line...
> 
>     my @resultsarray = $sth->fetchrow_array;
> 
> .... would return the row that I just inserted, or at least the primary
key
> of the new row (an autoincremented number).  But it doesn't of course, the
> @resultsarray is empty.  So my question is after I do an insert how can I
> immediately get ahold of the entry I just made?  Immediately doing a
SELECT
> right after the INSERT seems terribly inelegant.

Try doing a 
        select @@identity

right after the insert (on the same connection).

Michael
This e-mail is intended solely for the above-mentioned recipient and it may
contain confidential or privileged information.  If you have received it in
error, please notify us immediately and delete the e-mail.  You must not
copy, distribute, disclose or take any action in reliance on it.  In
addition, the contents of an attachment to this e-mail may contain software
viruses which could damage your own computer system.  While Electronic Ink,
Inc. and E Ink Ltd have taken every reasonable precaution to minimize this
risk, we cannot accept liability for any damage which you sustain as a
result of software viruses.  You should perform your own virus checks before
opening the attachment.

Reply via email to