Is it possible to to visualize a PL/SQL parse tree?

1.7k Views Asked by At

I'm looking for a means of somehow exporting or visualizing the parse tree of an arbitrary PL/SQL object in Oracle in such a way as to allow comparison between the parse trees of two similar objects. Is this possible?

1

There are 1 best solutions below

1
On BEST ANSWER

In theory this should be possible (and will need lots of time to implement!):

PL/SQL is parsed and stored in the DB as a tree-like structure PLUS m-code. The structure is some variant of DIANA plus IDL which in turn is something Ada uses to store the parse results too (PL/SQL is rather similar to Ada). For reference see http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/e_limits.htm and http://cs.felk.cvut.cz/10gr2/appdev.102/b14261/tuning.htm

Another option is to build your own parser - a starting point is http://it.toolbox.com/blogs/oracle-guide/building-a-plsql-code-parser-using-plsql-part-1-29704

A very helpful resource is http://www.blackhat.com/presentations/bh-usa-06/BH-US-06-Finnigan.pdf - you will find lots of information on how to extract DIANA-/IDL-information from an Oracle DB which should help you achieve your goal.