# some standard DBI code doing an INSERT here.. my $dbh = ...; my $sth = $dbh->prepare('...'); $sth->execute(@values); my $seq = 'SOME_SEQUENCE_NAME'; my $sth = $dbh->prepare("SELECT currval('$seq')"); $sth->execute() or die $dbh->errstr; if (my @row = $sth->fetchrow_array) { return $row[0]; }