HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

Using sys.diana and sys.pidl to parse PL/SQL

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlparsepidlsysusingdianaand

Problem

It seems to me that it should be possible to parse existing PL/SQL with the packages sys.diana and sys.pidl, but I have found nothing on the internet with the exception of a few scripts that seem to unwrap a wrapped package (and that is useless for my purposes).

So, does anyone know about a pointer into the right direction?

Solution

The official documentation covering unusual errors describes DIANA:

PL/SQL is based on the programming language Ada. As a result, PL/SQL uses a variant of Descriptive Intermediate Attributed Notation for Ada (DIANA), a tree-structured intermediate language. It is defined using a meta-notation called Interface Definition Language (IDL). DIANA is used internally by compilers and other tools.

At compile time, PL/SQL source code is translated into machine-readable m-code. Both the DIANA and m-code for a procedure or package are stored in the database. At run time, they are loaded into the shared memory pool. The DIANA is used to compile dependent procedures; the m-code is simply executed.

I see why you are interested. Access to the compiler underlying PL/SQL is tantalizing if you like looking under the hood. Nonetheless I would be reluctant to invest a lot of time
when the same goal can be accomplished by parsing with PL/SQL.

As someone who has used your site many times I can only thank you for having an inquiring mind.

Context

StackExchange Database Administrators Q#975, answer score: 3

Revisions (0)

No revisions yet.