The PARSE stored procedure is used to parse a DML statement (including SELECT) or to execute DDL or system commands.
The PARSE subprogram has the following versions:
Supports parameters of the
VARCHAR2type.Supports parameters of the
VARCHAR2AandVARCHAR2Stypes. For example, if the parameter is an array of strings, thePARSEstored procedure concatenates the strings in the array into an SQL statement and parses it.Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only 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 subprogram in a package is called, the package is 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.
Since client code cannot reference variables or constants in remote packages, you must explicitly use the values of constants. 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, procedure, function, or package using DBMS_SQL with compilation warnings, an error will be raised, and the PL unit will still be created.