Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

SQL::Parser and table aliases

by dargis05 (Initiate)
on Apr 11, 2011 at 20:00 UTC ( [id://898771]=perlquestion: print w/replies, xml ) Need Help??

dargis05 has asked for the wisdom of the Perl Monks concerning the following question:

The following code:
#!/usr/bin/perl use SQL::Statement; my $sqla = "update abc set a = 's' where a = 't' and amnt > 100"; my $sqlb = "update abc t set t.a = 's' where t.a = 't' and t.amnt > 1 +00"; my $parser = SQL::Parser->new(); $parser->{RaiseError}=1; $parser->{PrintError}=1; my $stmt = SQL::Statement->new($sqlb,$parser); my $columns = $stmt->column_defs() ; printf "Command %s\n",$stmt->command;
when run for $sqla works fine:
I get
Command UPDATE
When run with $sqlb, does not work
I get
Junk after table name 'abc'! at /usr/local/lib/perl5/site_perl/5.9.1/SQL/Statement.pm line 88
Junk after table name 'abc'! at /usr/local/lib/perl5/site_perl/5.9.1/SQL/Statement.pm line 88
Q: How could I make the SQL::Parser work with table aliases. Thanks,
D. Arg

Replies are listed 'Best First'.
Re: SQL::Parser and table aliases
by JavaFan (Canon) on Apr 11, 2011 at 20:24 UTC
    How could I make the SQL::Parser work with table aliases.
    By writing a patch. A quick browse through the POD of SQL::Statement::Syntax reveals that table aliases aren't supported syntax.
Re: SQL::Parser and table aliases
by mellon85 (Monk) on Apr 11, 2011 at 20:24 UTC
    AFAIK SQL update statements doesn't support table aliases

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://898771]
Approved by marto
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found