in reply to How to get inserted id from postgres

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]; ...