The returning clause basically turns your INSERT statement (also) into a SELECT statement, so after ->execute(), you want to ->fetch the result:
... my $sqlstatement = "insert into $table ($keylist) values ($qlist) +returning id"; my $sth = $dbh->prepare($sqlstatement); $sth->execute(@values) || die "Could not execute statement: $sqlst +atement $sth->errstr"; my $id = $sth->fetchall_arrayref->[0]->[0]; ...
In reply to Re: How to get inserted id from postgres
by Corion
in thread How to get inserted id from postgres
by cormanaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |