Maybe you should check out that your $dbh is still kosher by the time you get to running this identity query. Has it been reset or anything?

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.