how to read a variable upon insert?

From: Brian <signal(at)shreve(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: how to read a variable upon insert?
Date: 1999-04-14 03:51:01
Message-ID: Pine.LNX.4.10.9904132242030.32097-100000@mercury.shreve.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am running Postgres 6.3.2 and have a question.

I have a field, called "idnum", that automagically gets assigned a value
when something is inserted. I want to know that value when I do the
insert:

$sth = $dbh->prepare("INSERT INTO foo (bar) VALUES('$bar')");
$sth->execute;
$insertid = $sth->{'idnum'};

I would think that last line should be able to retreive it from the
statment handle, but it doesn't work.

Is the only way, to do *another* select after I insert and get the data?
I would hope after doing the insert, since I have the statment handle, I
could get the value.

Brian

-----------------------------------------------------
Brian Feeny (BF304) signal(at)shreve(dot)net
318-222-2638 x 109 http://www.shreve.net/~signal
Network Administrator ShreveNet Inc. (ASN 11881)

Browse pgsql-general by date

  From Date Subject
Next Message Gene Selkov, Jr. 1999-04-14 04:50:25 a propos printed books on postgresql
Previous Message The Hermit Hacker 1999-04-14 03:25:25 Re: [GENERAL] Would this project be of interest to anyone?