--- PApp-SQL/SQL.pm 2001/01/15 00:19:55 1.7 +++ PApp-SQL/SQL.pm 2001/01/22 10:53:36 1.8 @@ -197,9 +197,17 @@ =item $lastid = sql_insertid $sth -Returns the last automatically created key value (e.g. for mysql -AUTO_INCREMENT or sybase IDENTITY fields). It must be executed directly -after executing the insert statement that created it. +Returns the last automatically created key value. It must be executed +directly after executing the insert statement that created it. This is +what is actually returned for various databases. If your database is +missing, please send me an e-mail on how to implement this ;) + + mysql: first C column set to NULL + postgres: C column (is there a way to get the last SERIAL?) + sybase: C column of the last insert (slow) + informix: C or C column of the last insert + +Except for sybase, this does not require a server access. =cut @@ -208,8 +216,9 @@ my $dbh = $sth->{Database}; my $driver = $dbh->{Driver}{Name}; - $driver eq "mysql" and return $sth->{mysql_insertid}; - $driver eq "Sybase" and return sql_fetch($dbh, 'SELECT @@IDENTITY'); + $driver eq "mysql" and return $sth->{mysql_insertid}; + $driver eq "Pg" and return $sth->{pg_oid_status}; + $driver eq "Sybase" and return sql_fetch($dbh, 'SELECT @@IDENTITY'); $driver eq "Informix" and return $sth->{ix_sqlerrd}[1]; die "sql_insertid does not spport the dbd driver '$driver', please see PApp::SQL::sql_insertid";