Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Parsing SQL Statement

Re: Parsing SQL Statement

From: Nigel Thomas <nigel_cl_thomas_at_yahoo.com>
Date: Wed, 21 Mar 2007 09:00:05 -0700 (PDT)
Message-ID: <867124.71952.qm@web58702.mail.re1.yahoo.com>


Deepak

This question has been asked before - eg http://www.freelists.org/archives/oracle-l/09-2006/msg01064.html. Follow that thread to find various parsers (of greater or lesser value).

> Is there an easy way to extract the different parts of an SQL statement
> (SELECT, FROM, WHERE), in order to determine the columns being used,
> tables being accessed and columns being used in the where clause?

No, not an easy way. However if you restrict yourself to SELECTs, you can create a view and then - ALL/USER_TAB_COLUMNS tells you the columns being *projected* - ALL/USER_DEPENDENCIES tells you all the objects your view references directly (and then you can follow the dependency network to find indirect references)

> For simple SQL that has only one of the above clauses, may be simple (using substr, instr etc.),
> but it gets complicated with inline views, sub-queries etc.

It certainly does!

> Would "Oracle Text" be of any significance here in order to do the parsing?

Not really - that can tell you that the word 'SELECT' is near the word 'ORDER_ID' - but that's not precise enough. Even when you have a syntax tree, it's not always obvious which column in the select list goes with which table in the from clause.

Good luck with that...

Regards Nigel

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Mar 21 2007 - 11:00:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US