This procedure parses a statement on a specified cursor.
PROCEDURE EXEC_SQL.Parse
([Connid IN CONNTYPE,]
Curs_Id IN CURSTYPE,
Statement IN VARCHAR2
[Language IN PLS_INTEGER]);
Parameter | Description |
---|---|
Connid | Is the handle to the connection you want to use. If you do not specify a connection, EXEC_SQL.Default_Connection retrieves the primary Oracle Developer connection handle from the cache. |
Curs_Id | Is the cursor handle you want to assign the statement to. |
Statement | The SQL statement to be parsed. It should not include a final semicolon. |
Language_flag |
A flag that determines how Oracle handles the SQL statement. The valid
flags are: |
All SQL statements must be parsed using the Parse procedure. Parsing checks the syntax of the statement and associates it with the cursor in your code. Unlike OCI parsing, EXEC_SQL parsing is always immediate. You cannot defer EXEC_SQL parsing.
You can parse any data manipulation language (DML) or data definition language (DDL) statement. For Oracle data sources, the DDL statements are executed on the parse. For non-Oracle data sources, the DDL may be executed on the parse or on the execute. This means you should always parse and execute all DDL statements in EXEC_SQL.
PROCEDURE getData IS
connection_id EXEC_SQL.CONNTYPE;
cursorID EXEC_SQL.CURSTYPE;
sqlstr VARCHAR2(1000);
...
BEGIN
connection_id := EXEC_SQL.OPEN_CONNECTION(connect_str);
cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
--
-- the statement to be parsed is stored as a VARCHAR2 variable
--
sqlstr := 'select ename from emp';
--
-- perform parsing
--
EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
...
END;