With DBD::Pg and PostgreSQL, I do the following:
# 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]; }
The reason this works (I think) is that I am using the same $dbh as for an INSERT statement earlier in the code. That and PostgreSQL's way of doing this is better than TSQL's. I hated @@identity when I used to work with SQL Server.
I realise the difference here is that in Sybase (and MS SQL Server) TSQL you have to use @@identity, rather than just SELECT on a sequence. I hope this gives you some insight all the same. Maybe you should try and do this in 'raw DBI' first, and then use that to patch Class::DBI. If you get something that works please post it on this thread; I don't have access to a Sybase instance but I would still be interested.
That line in Class::DBI looks like it could use a polymorphic get_id method. I haven't used Class::DBI (yet) though so I won't comment further.
In reply to Re: Class::DBI && Sybase
by DapperDan
in thread Class::DBI && Sybase
by kal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |