The PARSE stored procedure is used to parse a DML statement (including SELECT) or execute other statements such as DDL and system commands.
The PARSE subprogram has the following multiple versions:
Supports parameters of the
VARCHAR2type.Supports parameters of the
VARCHAR2AandVARCHAR2Stypes. For example, if the parameter is an array of strings, thePARSEstored procedure will concatenate the strings in the array into an SQL statement for parsing.Applicability
This content applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition only provides MySQL mode.
Syntax
DBMS_SQL.PARSE(cursor_id IN INTEGER,
sql_stmt IN VARCHAR2,
language_flag IN INTEGER);
DBMS_SQL.PARSE(cursor_id IN INTEGER,
sql_stmt IN VARCHAR2A,
lb IN INTEGER,
ub IN INTEGER,
lfflg IN BOOLEAN,
language_flag IN INTEGER);
DBMS_SQL.PARSE(cursor_id IN INTEGER,
sql_stmt IN VARCHAR2s,
lb IN INTEGER,
ub IN INTEGER,
lfflg IN BOOLEAN,
language_flag IN INTEGER);
Parameters
| Parameter | Description |
|---|---|
| cursor_id | The cursor ID used to parse the statement or array. |
| sql_stmt | The SQL statement or array to be parsed. |
| lb | The lower bound of the array index. |
| ub | The upper bound of the array index. |
| lfflg | If the value is TRUE, a newline character is inserted after each cascading element. |
| language_flag | Specifies the behavior of the SQL statement. |
Considerations
Using DBMS_SQL to dynamically execute DDL statements may cause the program to stop responding. For example, if a package is locked when a subprogram in the package is called, the package remains locked until the execution returns to the client. Any lock operation that causes a conflict (such as attempting to drop the package before the first lock is released) will prevent the program from running.
Client-side code cannot reference variables or constants in remote packages, so the values of constants must be explicitly used. For example, the following code cannot be compiled on the client:
DBMS_SQL.PARSE (cur_hdl, stmt_str, DBMS_SQL.NATIVE);
-- Uses the constant DBMS_SQL.NATIVE
The following code is valid on the client because the parameters are explicitly provided:
DBMS_SQL.PARSE (cur_hdl, stmt_str, 1);
-- Compiled on the client
Exceptions
If you create a type, program, function, or package using DBMS_SQL with compilation warnings, an error will be raised, and the PL unit will still be created.