Skip Menu |

This queue is for tickets about the SQL-Statement CPAN distribution.

Report information
The Basics
Id: 30547
Status: rejected
Priority: 0/
Queue: SQL-Statement

People
Owner: JZUCKER [...] cpan.org
Requestors: Simon.Day [...] barclayscapital.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: <jeff [...] vpservices.com>
Subject: SQL-Statement-1.15 unable to parse multiple joins?
Date: Wed, 7 Nov 2007 14:37:18 -0000
To: <bug-SQL-Statement [...] rt.cpan.org>
From: <Simon.Day [...] barclayscapital.com>
Hi, I'm trying to parse a simple SQL statement and am getting an error. My statement has two inner joins at it seems that, at first sight, the parser has trouble with any more than one join (when I remove the second join, it works fine). Looking through the definitions for the supported syntax, it does indeed seem that only one join it allowed. If this is indeed the problem, is there any workaround? Many thanks in advance for any help Simon. My (simplified) code: my $parser = SQL::Parser->new("AnyData", { PrintError => 1 } ); my $success = $parser->parse("SELECT TH.ID FROM TRADE_HEADER TH INNER JOIN TRADE_ESPEED TR ON TH.COL1 = TR.COL1 INNER JOIN TRADE_STATUS TS ON TH.COL2 = TS.COL2 "); my $structure = $parser->structure; print("Success was $success Here is the result:\n"); pp($structure); The output: SQL ERROR: Table 'TR.COL1 INNER JOIN TRADE_STATUS TS ON TH' in WHERE clause not in FROM clause! SQL ERROR: No equijoin condition in WHERE or ON clause Success was Here is the result: { ORG_NAME => { "TRADE_HEADER.ID" => "TRADE_HEADER.ID" }, col_obj => { "TRADE_HEADER.ID" => bless({ display_name => "ID", function => undef, name => "ID", table => "TRADE_HEADER", }, "SQL::Statement::Util::Column"), }, column_aliases => { "TRADE_HEADER.ID" => "TRADE_HEADER.ID" }, column_names => ["TRADE_HEADER.ID"], command => "SELECT", errstr => "SQL ERROR: No equijoin condition in WHERE or ON clause\n\n", "join" => { clause => "ON" }, org_col_names => ["TRADE_HEADER.ID"], org_table_names => ["TRADE_HEADER", "TRADE_ESPEED"], original_string => "SELECT TH.ID\n FROM TRADE_HEADER TH\n INNER JOIN TRADE_ESPEED TR ON TH.COL1 = TR.COL1\n INNER JOIN TRADE_STATUS TS ON TH.COL2 = TS.COL2", set_function => undef, table_alias => { TRADE_ESPEED => ["tr"], TRADE_HEADER => ["th"] }, table_names => ["TRADE_HEADER", "TRADE_ESPEED"], } ------------------------------------------------------------------------ For important statutory and regulatory disclosures and more information about Barclays Capital, please visit our web site at http://www.barcap.com. Internet communications are not secure and therefore the Barclays Group does not accept legal responsibility for the contents of this message. Although the Barclays Group operates anti-virus programmes, it does not accept responsibility for any damage whatsoever that is caused by viruses being passed. Any views or opinions presented are solely those of the author and do not necessarily represent those of the Barclays Group. Replies to this email may be monitored by the Barclays Group for operational or business reasons. Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP. This email may relate to or be sent from other members of the Barclays Group. ------------------------------------------------------------------------
From: JZUCKER [...] cpan.org
On Wed Nov 07 09:38:12 2007, Simon.Day@barclayscapital.com wrote: Show quoted text
> Hi, > > I'm trying to parse a simple SQL statement and am getting an error. My > statement has two inner joins at it seems that, at first sight, the > parser has trouble with any more than one join (when I remove the > second > join, it works fine). Looking through the definitions for the > supported > syntax, it does indeed seem that only one join it allowed. > > If this is indeed the problem, is there any workaround? > > Many thanks in advance for any help > > Simon. > > > My (simplified) code: > > my $parser = SQL::Parser->new("AnyData", { PrintError => > 1 } ); > my $success = $parser->parse("SELECT TH.ID > FROM TRADE_HEADER TH > INNER JOIN TRADE_ESPEED TR ON TH.COL1 = TR.COL1 > INNER JOIN TRADE_STATUS TS ON TH.COL2 = TS.COL2 > "); > > my $structure = $parser->structure; > print("Success was $success Here is the result:\n"); > pp($structure); > > The output: > > SQL ERROR: Table 'TR.COL1 INNER JOIN TRADE_STATUS TS ON TH' in WHERE > clause not in FROM clause! > > SQL ERROR: No equijoin condition in WHERE or ON clause > > Success was Here is the result: > { > ORG_NAME => { "TRADE_HEADER.ID" => "TRADE_HEADER.ID" }, > col_obj => { > "TRADE_HEADER.ID" => bless({ > display_name => "ID", > function => undef, > name => "ID", > table => "TRADE_HEADER", > }, "SQL::Statement::Util::Column"), > }, > column_aliases => { "TRADE_HEADER.ID" => "TRADE_HEADER.ID" }, > column_names => ["TRADE_HEADER.ID"], > command => "SELECT", > errstr => "SQL ERROR: No equijoin condition in WHERE or ON > clause\n\n", > "join" => { clause => "ON" }, > org_col_names => ["TRADE_HEADER.ID"], > org_table_names => ["TRADE_HEADER", "TRADE_ESPEED"], > original_string => "SELECT TH.ID\n FROM TRADE_HEADER TH\n > INNER > JOIN TRADE_ESPEED TR ON TH.COL1 = TR.COL1\n INNER JOIN TRADE_STATUS > TS ON TH.COL2 = TS.COL2", > set_function => undef, > table_alias => { TRADE_ESPEED => ["tr"], TRADE_HEADER => ["th"] > }, > table_names => ["TRADE_HEADER", "TRADE_ESPEED"], > } > ------------------------------------------------------------------------ > For important statutory and regulatory disclosures and more > information about Barclays Capital, please visit our web site at > http://www.barcap.com. > > Internet communications are not secure and therefore the Barclays > Group does not accept legal responsibility for the contents of this > message. Although the Barclays Group operates anti-virus > programmes, it does not accept responsibility for any damage > whatsoever that is caused by viruses being passed. Any views or > opinions presented are solely those of the author and do not > necessarily represent those of the Barclays Group. Replies to this > email may be monitored by the Barclays Group for operational or > business reasons. > > Barclays Capital is the investment banking division of Barclays Bank > PLC, a company registered in England (number 1026167) with its > registered office at 1 Churchill Place, London, E14 5HP. This email > may relate to or be sent from other members of the Barclays Group. > ------------------------------------------------------------------------
RT-Send-CC: Simon.Day [...] barclayscapital.com
Sorry, I don't consider something that works the way the documentation says it should work to be a bug. Would it be nice if the module supported more than two joins per statement, sure. Patches gladly accepted.
RT-Send-CC: Simon.Day [...] barclayscapital.com
Sorry, I don't consider something that works the way the documentation says it should work to be a bug. Would it be nice if the module supported more than two joins per statement, sure. Patches gladly accepted.