Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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:
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.
|
|---|