Oracle PL/SQL Tutorial/SQL PLUS Session Environment/PLSQL OPTIMIZE LEVEL — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:45, 26 мая 2010

Check $$PLSQL_OPTIMIZE_LEVEL

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> DECLARE
  2     l_postproc_code   dbms_preprocessor.source_lines_t;
  3     l_row             PLS_INTEGER;
  4  BEGIN
  5     l_postproc_code := dbms_preprocessor.get_post_processed_source ("PROCEDURE", USER, "POST_PROCESSED");
  6     l_row := l_postproc_code.FIRST;
  7
  8     WHILE (l_row IS NOT NULL)
  9     LOOP
 10        DBMS_OUTPUT.put_line (LPAD (l_row, 3)|| " - "|| rtrim ( l_postproc_code (l_row),chr(10)));
 11        l_row := l_postproc_code.NEXT (l_row);
 12     END LOOP;
 13
 14  END;
 15  /
PL/SQL procedure successfully completed.


$IF $$plsql_optimize_level

SQL>
SQL> CREATE OR REPLACE PROCEDURE check_expressions
  2  IS
  3  BEGIN
  4  $IF $$plsql_optimize_level != 1 OR $$plsql_optimize_level = 2
  5  $THEN
  6     -- Placeholder
  7  $END
  8     NULL;
  9  END check_expressions;
 10  /
Procedure created.


$IF $$plsql_optimize_level IS NULL OR $$plsql_optimize_level IS NOT NULL

SQL> CREATE OR REPLACE PROCEDURE check_expressions
  2  IS
  3  BEGIN
  4
  5  $IF $$plsql_optimize_level IS NULL OR $$plsql_optimize_level IS NOT NULL
  6  $THEN
  7     -- Placeholder
  8  $END
  9     NULL;
 10  END check_expressions;
 11  /
Procedure created.
SQL>