how to read a variable upon insert? - Mailing list pgsql-general

From Brian
Subject how to read a variable upon insert?
Date
Msg-id Pine.LNX.4.10.9904132242030.32097-100000@mercury.shreve.net
Whole thread Raw
List 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@shreve.net
318-222-2638 x 109    http://www.shreve.net/~signal
Network Administrator   ShreveNet Inc. (ASN 11881)


pgsql-general by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [GENERAL] Would this project be of interest to anyone?
Next
From: "Gene Selkov, Jr."
Date:
Subject: a propos printed books on postgresql