On Wed, 19 Dec 2012 15:58:26 +0100 Jens Rehsack <rehs...@cpan.org> wrote:
> > > > -------- Original Message -------- > Subject: SQL::Statement (SQL-Statement-1.402_002) > Date: Wed, 19 Dec 2012 15:53:31 +0100 > From: Thomas Binder <tcb...@gmail.com> > To: rehs...@cpan.org > > 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 : [...] > Can't call method "name" on unblessed reference at test.pl > <http://test.pl> line 14. I think you can leave off the map part. $stmt->column_defs() just returns a list of names, which is what you would want to pass to join. So, line 14 should be this: printf "Columns %s\n",join( ',', $stmt->column_defs() ); I see where you got that line from in the Synopsis of SQL::Statement::Structure; however, judging from the description of the column_defs method further down, that line is wrong. -- C. Chad Wallace, B.Sc. The Lodging Company http://www.lodgingcompany.com/ OpenPGP Public Key ID: 0x262208A0