Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://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 (http://lists.scsys.co.uk/pipermail/dbix-class/2012-June/010553.html). 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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found