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


in reply to Saving data to XML file using DBD::AnyData

I added the following to the top of your program to get a trackback dump:
use Carp; $SIG{__DIE__} = \&Carp::confess;
This indicated that DBD::AnyData is dying on the following line of code in the ad_data method:
my $sth = $dbh->prepare("SELECT 1 FROM $table_name") or die DBI- +>errstr;
I then wrote the following test program to exercise SQL::Statement directly:
use common::sense; use SQL::Statement; my $sql1 = "SELECT 1+0 FROM some_table"; my $sql2 = "SELECT 1 FROM some_table"; my $parser = SQL::Parser->new(); for ($sql1, $sql2) { warn "trying: $_"; my $stmt = SQL::Statement->new($_,$parser); }
This produces:
trying: SELECT 1+0 FROM some_table at sql.pl line 10. trying: SELECT 1 FROM some_table at sql.pl line 10. Bad table or column name: '1' starts with non-alphabetic character! at + /usr/local/share/perl/5.10.0/SQL/Parser.pm line 2894.
So "SELECT 1+0 from some_table" parses ok, but "SELECT 1 from some_table" doesn't!

I started with SQL::Statement 1.20. The problem persisted after upgrading to 1.23.

Looks to me like a bug in SQL::Statement. Its not recognising the literal value '1' as a simple expression. My guess is that this has stopped working in the last few releases of SQL::Statement, but DBD::AnyData relies on it.

Update: I've created an rt ticket.

Replies are listed 'Best First'.
Re^2: Saving data to XML file using DBD::AnyData
by warsting (Novice) on Dec 04, 2009 at 17:01 UTC

    Thanks for the in depth debugging. Being the AnyData module was new to me, I wasn't sure on how to get at that error message.