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

Hi Monks,

I have a sql statement like

Select e.empno as employee, e.deptno as department, d.loc as location + from emp e,dept d where e.deptno= d.deptno;

I need to parse the above sql statement to get the columns and tables used. So my output should be the columns (empno,deptno,loc)and tables (emp, dept). I need this to be done with PERL script and i dont have that much knowledge in PERL.

It would be a great help for any small hint also..

Thanks for your valuable time..

Regards,
Rahul

Code tags added by GrandFather

Replies are listed 'Best First'.
Re: SQL Parsing
by Corion (Patriarch) on Apr 07, 2008 at 06:06 UTC

    Usually, SQL::Statement can parse such SQL statements. What code have you already written and where do you encounter problems with your approach?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: SQL Parsing
by Ovid (Cardinal) on Apr 10, 2008 at 14:06 UTC