develooper Front page | perl.dbi.users | Postings from December 2012

Fwd: SQL::Statement (SQL-Statement-1.402_002)

Thread Next
From:
Jens Rehsack
Date:
December 19, 2012 14:58
Subject:
Fwd: SQL::Statement (SQL-Statement-1.402_002)
Message ID:
50D1D612.1010705@cpan.org



-------- Original Message --------
Subject: 	SQL::Statement (SQL-Statement-1.402_002)
Date: 	Wed, 19 Dec 2012 15:53:31 +0100
From: 	Thomas Binder <tcbind@gmail.com>
To: 	rehsack@cpan.org



Hi there,

I have a little problem with SQL-Statement.

I installed it on two different systems (Linux+Windows) using Perl v5.14.
The installation went w/o a hitch, also "make test" showed no issues :

All tests successful.

Test Summary Report
-------------------
t/06virtual.t    (Wstat: 0 Tests: 677 Failed: 0)
    TODO passed:   587-589
t/08join.t       (Wstat: 0 Tests: 321 Failed: 0)
    TODO passed:   289-291, 293-295, 314, 316, 318, 321
Files=16, Tests=1639,  7 wallclock secs ( 0.55 usr  0.06 sys +  6.92
cusr  0.30 csys =  7.83 CPU)
Result: PASS

However, when I try your example from the docs of SQL::Statement::Structure

use SQL::Statement;
my $sql    = "SELECT a FROM b JOIN c WHERE c=? AND e=7 ORDER BY f DESC
LIMIT 5,2";
my $parser = SQL::Parser->new();
$parser->{RaiseError}=1;
$parser->{PrintError}=0;
# $parser->parse("LOAD 'MyLib::MySyntax' ");
my $stmt = SQL::Statement->new($sql,$parser);
printf "Command             %s\n",$stmt->command;
printf "Num of Placeholders %s\n",scalar $stmt->params;
printf "Tables              %s\n",join( ',', map {$_->name}
$stmt->tables() );
printf "Where operator      %s\n",join( ',', $stmt->where->op() );
printf "Limit               %s\n",$stmt->limit();
printf "Offset              %s\n",$stmt->offset();
printf "Columns             %s\n",join( ',', map {$_->name}
$stmt->column_defs() );

I get this result :

Command             SELECT
Num of Placeholders 1
Tables              b,c
Where operator      AND
Limit               2
Offset              5
Can't call method "name" on unblessed reference at test.pl
<http://test.pl> line 14.

So, I'm unable to use *column_defs()* correctly. Any idea ?

I would be happy, to hear from you.

Best regards & A Merry Christmas

Thomas Binder




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About