Oct 24, 2011, 6:24 PM
Post #1 of 3
SQL::Statement and adding syntax
I am trying to use the SQL::Statement module (1.33) to parse SQL statements from DB2. I do not need to execute them, just find the involved tables and columns in context. The module does not support some of DB2's peculiarities out of the box even in the few core SQL commands that are supported (such as WITH and FOR clauses used for some optimizations.) The documentation discuss the possibility of adding syntax but is very sparse in explaining how. So here are my questions:
1. It is not clear how to create a file to satisfy
$parser->parse("LOAD 'MyLib::MySyntax' ");
I understand that by sifting through all documentation I should be able to figure it out, but does any of you, by a chance, have some samples and/or more detailed documentation that could expedite my understanding.
2. Similarly, assuming that I want the package to recognize the DATE function of DB2 as far as I am concerned (since I do only syntax parsing), the function could do nothing, maybe return the input parameter as is. What should be therefore the syntax for
$parser->parse("CREATE FUNCTION DATE ...");
so I won't get an error message such as
"Can't locate object method "do_er" via package "SQL::Statement" at C:/Perl/lib/SQL/Statement/Function.pm line 134, <IFILE> line 728."
3. If that would work for me, I may add some of the problematic keywords such as WITH, FOR and so on (that DB2 use for optimization, etc.) and be done with... but I need to know how!
I am pretty good in using Perl, but I couldn't find (yet) any obvious place in the documentation to answer these questions.
Thank you so much