Oracle PL/SQL Tutorial/System Packages/dbms preprocessor
dbms_preprocessor.print_post_processed_source
SQL>
SQL> CREATE OR REPLACE PROCEDURE post_processed
2 IS
3 BEGIN
4 $IF $$PLSQL_OPTIMIZE_LEVEL = 1
5 $THEN
6 -- Slow and easy
7 NULL;
8 $ELSE
9 -- Fast and modern and easy
10 NULL;
11 $END
12 END post_processed;
13 /
Procedure created.
SQL>
SQL> BEGIN
2 dbms_preprocessor.print_post_processed_source ("PROCEDURE", USER, "POST_PROCESSED");
3 END;
4 /
PL/SQL procedure successfully completed.
View the post-processed source
SQL>
SQL>
SQL> SET SERVEROUTPUT ON PAGES 9999
SQL>
SQL> CREATE OR REPLACE PROCEDURE compile_by_version
2 IS
3
4 BEGIN
5 $IF DBMS_DB_VERSION.VER_LE_10_2
6 $THEN
7 DBMS_OUTPUT.PUT_LINE("10.2 and under");
8 $ELSIF DBMS_DB_VERSION.VER_LE_10_1
9 $THEN
10 DBMS_OUTPUT.PUT_LINE("10.1 and under");
11 $ELSE
12 DBMS_OUTPUT.PUT_LINE("Not 10g");
13 $END
14
15 END;
16 /
Procedure created.
SQL>
SQL> BEGIN
2 DBMS_PREPROCESSOR.PRINT_POST_PROCESSED_SOURCE (
3 "PROCEDURE",
4 "PLSQL",
5 "COMPILE_BY_VERSION");
6 END;
7 /
BEGIN
SQL>
SQL>