in reply to Re: DBD::Sybase prepare statement returns empty query hash but no errstr
in thread DBD::Sybase prepare statement returns empty query hash but no errstr

I printed out $dbh->{Statement}, and I can see my query now. When I have the trace set to 6, these are the messages I get:

-> prepare for DBD::Sybase::db (DBI::db=HASH(0x80a2254)~0x80a21c4 +'declare @skiprows int, @getrows int; select @skiprows = 0; select @g +etrows = 10000; set rowcount @skiprows; select * into #debt from debt + order by debt_id, debt_no asc; set rowcount @getrows;select * from d +ebt where (debt_id NOT IN ( select * from #debt ) ) ORDER BY debt_id, + debt_no ASC') thr#804d1a0 New 'DBI::st' (for DBD::Sybase::st, parent=DBI::db=HASH(0x80a21c4) +, id=undef) dbih_setup_handle(DBI::st=HASH(0x80ab054)=>DBI::st=HASH(0x80a2304) +, DBD::Sybase::st, 80ab014, Null!) dbih_make_com(DBI::db=HASH(0x80a21c4), 80a9804, DBD::Sybase::st, 4 +20, 0) thr#804d1a0 dbih_setup_attrib(DBI::st=HASH(0x80a2304), Err, DBI::db=HASH(0x80a +21c4)) SCALAR(0x81d0754) (already defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), State, DBI::db=HASH(0x8 +0a21c4)) SCALAR(0x81d07b4) (already defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), Errstr, DBI::db=HASH(0x +80a21c4)) SCALAR(0x81d0784) (already defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), TraceLevel, DBI::db=HAS +H(0x80a21c4)) 6 (already defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), FetchHashKeyName, DBI:: +db=HASH(0x80a21c4)) 'NAME_lc' (already defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), HandleSetErr, DBI::db=H +ASH(0x80a21c4)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), HandleError, DBI::db=HA +SH(0x80a21c4)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), ReadOnly, DBI::db=HASH( +0x80a21c4)) undef (not defined) dbih_setup_attrib(DBI::st=HASH(0x80a2304), Profile, DBI::db=HASH(0 +x80a21c4)) undef (not defined) syb_st_prepare() -> inUse = 0 syb_st_prepare() -> set inUse <- prepare= ( DBI::st=HASH(0x80ab054) ) [1 items] at export_debt.p +l line 62 <> FETCH= ( 'declare @skiprows int, @getrows int; select @skiprows + = 0; select @getrows = 10000; 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 ) ) OR +DER BY debt_id, debt_no ASC' ) [1 items] ('Statement' from cache) at +/usr/lib/perl5/site_perl/5.28.2/i686-linux-thread-multi/Data/Dumper.p +m line 604 via at export_debt.pl line 78

It then sits there, not doing the query. Is there something wrong with trying to do multiple statements thru dbd::Sybase? Or, is there something wrong with my query?

  • Comment on Re^2: DBD::Sybase prepare statement returns empty query hash but no errstr
  • Download Code

Replies are listed 'Best First'.
Re^3: DBD::Sybase prepare statement returns empty query hash but no errstr
by jcb (Parson) on Oct 30, 2019 at 23:57 UTC

    DBI is pretty firmly in the "prepare one statement at a time" camp. I am not familiar with DBD::Sybase; are you sure that that entire statement group is not being parsed as "declare @skiprows int, @getrows int; <unparsed leftovers>" which does nothing and returns nothing?

      At least the doc claims "DBD::Sybase has the ability to handle multi-statement SQL commands in a single batch."

      OTOH, "ability" alone doesn't say it will work under all circumstances...

        DBD::SQLite also has that ability, but will only do so if you ask for it. Could there be a flag you must set on the database or statement handle to enable the feature?

Re^3: DBD::Sybase prepare statement returns empty query hash but no errstr
by poj (Abbot) on Oct 31, 2019 at 15:45 UTC
    is there something wrong with my query?

    Maybe but I'm having difficulty understanding it

    select * into #debt from debt makes a temporary copy of debt.

    Next query looks for records in debt that are not in the copy #debt.

    select * from debt where (debt_id NOT IN ( select * from #debt ) )
    I wouldn't expect there to be any ?

    poj

      When I run the query in Sqlexec, I get results. I ended up going a different route by selecting distinct debtor_ids, and then taking slices of the array and selecting from the database where debtor_id IN ($ids). And that is working.