Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

SQL::Parser and table aliases

by dargis05 (Initiate)
on Apr 11, 2011 at 20:00 UTC ( #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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-23 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?