I am trying to prepare a multi-statement query as referenced here: https://metacpan.org/pod/DBD::Sybase

When I use the prepare statement, and then use Data::Dumper, it returns an empty hash:

$VAR1 = bless( {}, 'DBI::st' );

When I use dbh->trace(3), I get the following:

-> prepare for DBD::Sybase::db (DBI::db=HASH(0x80a2974)~0x80a28e4 'de +clare @skiprows int, @getrows int; select @skiprows = 0; select @getr +ows = 10000; set rowcount @skiprows; select * into #debt from debt or +der by debt_id, debt_no asc; set rowcount @getrows;select * from debt + where (debt_id NOT IN ( select * from #debt ) ) ORDER BY debt_id, de +bt_no ASC') thr#804d1a0 syb_st_prepare() -> inUse = 0 syb_st_prepare() -> set inUse <- prepare= ( DBI::st=HASH(0x80b2884) ) [1 items] at export_debt.p +l line 52 -> errstr in DBD::_::common for DBD::Sybase::db (DBI::db=HASH(0x80 +a2974)~0x80a28e4) thr#804d1a0 <- errstr= ( '' ) [1 items] at export_debt.pl line 63 err $VAR1 = ''; -> FIRSTKEY in DBD::_::common for DBD::Sybase::st (DBI::st=HASH(0x +80a2a24)~INNER) thr#804d1a0 <- FIRSTKEY= ( undef ) [1 items] at Dumper.pm line 232 via at Dum +per.pm line 604

Here is the code in question:

my $getrows = 10000; my $skiprows = 0; my $i = 0; $db->{dbh}->trace(3); my $query = $db->{dbh}->prepare( "declare \@skiprows int, \@getrows i +nt; " . "select \@skiprows = $skiprows; " . "select \@getrows = $getrows; " . "set rowcount \@skiprows; " . "select * into #debt from debt " . "order by debt_id, debt_no asc; " . "set rowcount \@getrows;" . "select * from debt where " . "(debt_id NOT IN ( select * from #debt ) ) " . "ORDER BY debt_id, debt_no ASC" ); print STDERR "err\n", Dumper( $db->{dbh}->errstr ); print STDERR "query\n", Dumper($query);

I am not sure what I am doing wrong, and I can't get enough information to tell me what is going on.

Any help would be appreciated.

Thanks.


In reply to DBD::Sybase prepare statement returns empty query hash but no errstr by Anonymous Monk

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.