You can use the DBMS_PREPROCESSOR package to display or retrieve the source text of your program in its postprocessed form. DBMS_PREPROCESSOR offers two programs, overloaded to allow you to specify the object of interest in various ways, as well as to work with individual strings and collections: DBMS_PREPROCESSOR.PRINT_POST_PROCESSED_SOURCE
DBMS_PREPROCESSOR.GET_POST_PROCESSED_SOURCE
When working with the collection version of either of these programs, you will need to declare that collection based on the following package-defined collection: TYPE DBMS_PREPROCESSOR.source_lines_t IS TABLE OF VARCHAR2(32767) The following sequence demonstrates the capability of these programs. I compile a very small program with a selection directive based on the optimization level. I then display the postprocessed code, and it shows the correct branch of the $IF statement. /* File on web: cc_postprocessor.sql END post_processed; SQL> BEGIN PROCEDURE post_processed In the following block, I use the “get” function to retrieve the postprocessed code, and then display it using DBMS_OUTPUT.PUT_LINE: DECLARE WHILE (l_row IS NOT NULL) Conditional compilation opens up all sorts of possibilities for PL/SQL developers and application administrators. And its usefulness only increases as new versions of Oracle are released and the DBMS_DB_VERSION constants can be put to full use, allowing us to take full advantage of each version’s unique PL/SQL features.
blog comments powered by Disqus |