Обсуждение: how to read a variable upon insert?

Поиск
Список
Период
Сортировка

how to read a variable upon insert?

От
Brian
Дата:
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)