CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
SQL::Statement and adding syntax

 



zatlas1
Novice

Oct 24, 2011, 6:24 PM

Post #1 of 3 (670 views)
SQL::Statement and adding syntax Can't Post

Hi all

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

ZA


zatlas1
Novice

Oct 24, 2011, 7:31 PM

Post #2 of 3 (661 views)
Re: [zatlas1] SQL::Statement and adding syntax [In reply to] Can't Post

Doing
$parser->parse("CREATE FUNCTION DATE");

seems to be the correct way to go for adding functions, but does anybody know what the error message means?

"Can't locate object method "do_er" via package "SQL::Statement" at C:/Perl/lib/SQL/Statement/Function.pm line 134, <IFILE> line 728."


ZA


zatlas1
Novice

Oct 24, 2011, 8:36 PM

Post #3 of 3 (658 views)
Re: [zatlas1] SQL::Statement and adding syntax [In reply to] Can't Post

Well, I researced this and fixed the bug (in the SQL::Statement package)

The function.pm file contains two places where it says do_er rather then do_err (lines 131 and 134). When I fixed that it worked as advertised.

I reported the bug via email.

ZA

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives