The GET_POST_PROCESSED_SOURCE function is used to obtain the PL source code after conditional compilation processing, returning a source_lines_t collection type.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
The GET_POST_PROCESSED_SOURCE function supports the following three overloaded forms:
Obtain by object type, schema name, and object name
DBMS_PREPROCESSOR.GET_POST_PROCESSED_SOURCE(
object_type VARCHAR2,
schema_name VARCHAR2,
object_name VARCHAR2)
RETURN source_lines_t;
Obtain by source code string
DBMS_PREPROCESSOR.GET_POST_PROCESSED_SOURCE(
source VARCHAR2)
RETURN source_lines_t;
Obtain by source code collection
DBMS_PREPROCESSOR.GET_POST_PROCESSED_SOURCE(
source source_lines_t)
RETURN source_lines_t;
Parameters
Parameter |
Description |
|---|---|
| object_type | The type of PL object to process. Supported types include: PACKAGE, PACKAGE BODY, PROCEDURE, FUNCTION, TRIGGER, TYPE, and TYPE BODY. |
| schema_name | The name of the schema to which the object belongs. If NULL, the current schema is used. |
| object_name | The name of the object. |
| source | A PL source code string or a source_lines_t collection. |
Return value
Returns a source_lines_t collection type, defined as follows:
TYPE source_lines_t IS
TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER;
Usage notes
- The overloaded form by object type, schema name, and object name retrieves the source code of the PL object from the data dictionary and performs preprocessing.
- The overloaded form by source code string directly preprocesses the passed-in string.
- Each line in the result corresponds to one line of preprocessed source code.
- The overloaded form by source code collection is not currently supported.
Example
DECLARE
result DBMS_PREPROCESSOR.source_lines_t;
i BINARY_INTEGER;
BEGIN
result := DBMS_PREPROCESSOR.GET_POST_PROCESSED_SOURCE(
'CREATE OR REPLACE PACKAGE my_pkg IS
$IF DBMS_DB_VERSION.VER_LE_21 $THEN
SUBTYPE my_type IS NUMBER;
$ELSE
SUBTYPE my_type IS VARCHAR2(100);
$END
PROCEDURE p;
END;');
i := result.FIRST;
WHILE i IS NOT NULL LOOP
DBMS_OUTPUT.PUT_LINE(result(i));
i := result.NEXT(i);
END LOOP;
END;
/
