http://www.perlmonks.org?node_id=983324


in reply to Re^4: Debian DBD::ODBC select row by timestamp
in thread Debian DBD::ODBC select row by timestamp

Can we see the script and the actual error messsage for the second case (including line number). The first case just needed quotes adding.

  • Comment on Re^5: Debian DBD::ODBC select row by timestamp

Replies are listed 'Best First'.
Re^6: Debian DBD::ODBC select row by timestamp
by alexx_sh (Novice) on Jul 24, 2012 at 09:18 UTC
    Yes.
    use strict; use warnings; use DBI; use Data::Dumper; use JSON::XS; my $dbh = DBI->connect (q{DBI:ODBC:test}) or die $DBI::errstr; my $sth = $dbh-> prepare("SELECT val from buf WHERE dd_mm_yyyy= ? ") o +r die $dbh->errstr(); $sth->execute('2012-07-22 00:00:00') or die $dbh->errstr(); my $table; my $tbl_ary_ref; $tbl_ary_ref = $sth->fetchall_arrayref; if (defined $tbl_ary_ref){ $table->{date} = $tbl_ary_ref; } $tbl_ary_ref = encode_json $table; print qq{JSON-------------------JSON\n}; print $tbl_ary_ref."\n"; $sth->finish; $dbh->disconnect;
    And output:
    Error at Line : syntax error near ? JSON-------------------JSON {"date":[]}

      That Perl looks syntactically correct to me so I assume the message comes from MS Access and yet if that were the case your script would have died at line 11 or 12. The output with the JSON seems to confirm that. Are you sure that is the script you are running?

        Yes i check script. And i can't undestand why it dosn't work. How enable debug output in unixodbc?

        So if i edit script:

        SELECT val from buf WHERE (dd_mm_yyyy= {ts '2012-07-22 00:00:00'})

        i have output like this

        Calling mdb_test_sarg on unknown type. Add code to mdb_test_sarg() fo +r type 8 Calling mdb_test_sarg on unknown type. Add code to mdb_test_sarg() fo +r type 8 JSON-------------------JSON {"date":[[""],[""]]}

        I think it's driver error libmdbodbc.

        Seemed it don't work properly.