Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Hello most gracious monks,

I was happily writing a Catalyst app with DBIx::Class when I tripped over some database problem. I haven't been able to pin it down, but I'm pretty sure it has to do with DBD::Sybase used with our MSSQL server.

My original problem is I tried to call ->first on a DBIx::Class::ResultSet twice. That produced the error "DBIx::Class::ResultSet::first(): Unknown error: execute() returned false, but error flags were not set...", which you can find in DBIx::Class::Storage::DBI in sub _dbh_execute.

# Can this fail without throwing an exception anyways??? my $rv = $sth->execute(); $self->throw_exception( $sth->errstr || $sth->err || 'Unknown error: execute() returned fa +lse, but error flags were not set...' ) if !$rv;

I have a minimal test using only DBI that demonstrates the problem.

use 5.014; use strict; use warnings; use DBI; use Test::More; my @connect_info = ( "dbi:Sybase:server=xxx;database=xxx", 'xxx', ':)', { RaiseError => 1 }, ); # @connect_info = ("dbi:SQLite2:dbname=dbfile","",""); my $dbh = DBI->connect( @connect_info ); isa_ok $dbh, 'DBI::db'; my $sql = 'SELECT 1'; test_query( $sql ); test_query( $sql ); sub test_query { my ($sql) = @_; my $sth = $dbh->prepare_cached( $sql ); isa_ok $sth, 'DBI::st'; my $r = $sth->execute(); { no warnings 'uninitialized'; ok defined( $r ), "defined: '$r'"; } ok $sth->finish(), '$sth->finish'; return; } done_testing;

I've obscured the actual connect info. This is what the output looks like:

ok 1 - The object isa DBI::db ok 2 - The object isa DBI::st ok 3 - defined: '-1' ok 4 - $sth->finish ok 5 - The object isa DBI::st not ok 6 - defined: '' # Failed test 'defined: ''' # at t/dbi-bug-pm.t line 35. ok 7 - $sth->finish 1..7 # Looks like you failed 1 test of 7.

Note that if you uncomment the SQLite connect info, it works fine. That's why I think this is a problem with my database or driver. You can see a run with SQLite below.

ok 1 - The object isa DBI::db ok 2 - The object isa DBI::st ok 3 - defined: '0E0' ok 4 - $sth->finish ok 5 - The object isa DBI::st ok 6 - defined: '0E0' ok 7 - $sth->finish 1..7

Note also that if I disconnect from the database and reconnect between the queries, they work, but I don't think disconnecting from the database after every query is a very good workaround.

I'd be happy with a workaround for this issue. If I could stick some code in every ResultSet so that it avoids the problem until it's fixed elsewhere, that would be fine with me, but I don't even understand what's going wrong. I'm asking here to see if someone is familiar with it and what it means.

My searching for the issue online turned up a thread from about a year ago ( If there's an answer in there, I failed to comprehend it.

Any help would be appreciated. Thank you.

In reply to My MSSQL query fails the second time. by kyle

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (17)
    As of 2018-07-23 14:01 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (468 votes). Check out past polls.