Call Sequences for APEX_EXEC
All APEX_EXEC procedures require an existing APEX session to function. In a pure SQL or PL/SQL context, use the APEX_SESSION package to initialize a new session.
See Also: APEX_SESSION
Querying a Data Source with APEX_EXEC
-
Prepare columns to be selected from the data source:
-
Create a variable of the
APEX_EXEC.T_COLUMNStype. -
Add columns with the
APEX_EXEC.ADD_COLUMN.
-
-
(Optional) Prepare bind variables:
-
Create a variable of
APEX_EXEC.T_PARAMETERStype. -
Add bind values with
APEX_EXEC.ADD_PARAMETER.
-
-
(Optional) Prepare filters:
-
Create a variable of the type
APEX_EXEC.T_FILTERS. -
Add bind values with
APEX_EXEC.ADD_FILTER.
-
-
Execute the data source query in one of the following ways:
-
For REST Data Sources, use
APEX_EXEC.OPEN_REST_SOURCE_QUERY. -
For REST Enabled SQL, use
APEX_EXEC.OPEN_REMOTE_SQL_QUERY. -
Alternatively, use
APEX_EXEC.OPEN_QUERY_CONTEXTto pass in the location as a parameter.
-
-
Get the result set meta data:
-
APEX_EXEC.GET_COLUMN_COUNTreturns the number of result columns. -
APEX_EXEC.GET_COLUMNreturns information about a specific column.
-
-
Process the result set:
-
APEX_EXEC.NEXT_ROWadvances the result cursor by one row. -
APEX_EXEC.GET_NNNNfunctions retrieve individual column values.
-
-
Close all resources with
APEX_EXEC.CLOSE. -
Add an exception handler and close those resources. For example:
EXCEPTION WHEN others THEN apex_debug.log_exception; apex_exec.close( l_context ); RAISE;
See Also:
For code examples of a complete query to a Data Source, review the example sections in the following APIs:
Executing a DML on a Data Source with APEX_EXEC
-
Define the Data Manipulation Language (DML) columns:
-
Create a variable of the
APEX_EXEC.T_COLUMNStype. -
Add columns with
APEX_EXEC.ADD_COLUMN.
-
-
(Optional) Prepare bind variables:
-
Create a variable of the
APEX_EXEC.T_PARAMETERStype. -
Add bind values with
APEX_EXEC.ADD_PARAMETER.
-
-
Prepare the DML Context in one of the following ways:
-
For REST Data Sources, use
OPEN_REST_SOURCE_DML_CONTEXT. -
For REST Enabled SQL, use
OPEN_REMOTE_DML_CONTEXT. -
For local database, use
OPEN_LOCAL_DML_CONTEXT.
-
-
Add row values for the DML to perform:
-
Use
APEX_EXEC.ADD_DML_ROWto add a new row. -
Use
APEX_EXEC.SET_VALUEto provide individual column values.
-
-
Execute the DML with
APEX_EXEC.EXECUTE_DML. -
Walk through RETURNING values and error messages for processed DML rows.
-
APEX_EXEC.NEXT_ROWadvances the result cursor by one row. -
APEX_EXEC.HAS_ERRORindicates whether DML processing for this row was successful or not. -
APEX_EXEC.GET_DML_STATUS_CODEreturns the status code (SQL Error Code) for each DML row. If DML for this row was successful, NULL is returned as the status code. -
APEX_EXEC.GET_NNNfunctions retrieve individual column “DML RETURNING” values.
-
-
Close all resources with
APEX_EXEC.CLOSE. -
Add an exception handler and close those resources. For example:
EXCEPTION WHEN others THEN apex_exec.close( l_context ); RAISE;
See Also:
For code examples of a complete DML query, review the example sections in the following APIs:
Executing a Remote Procedure or REST API with APEX_EXEC
-
(Optional) Prepare bind variables:
-
Create a variable of
APEX_EXEC.T_PARAMETERStype. -
Add bind values with
APEX_EXEC.ADD_PARAMETER.
-
-
Execute the local or remote procedure or REST API in one of the following ways:
-
For REST Data Sources, use
APEX_EXEC.EXECUTE_REST_SOURCE. -
For REST Enabled SQL, use
APEX_EXEC.EXECUTE_REMOTE_PLSQL. -
For local database, use
APEX_EXEC.EXECUTE_PLSQL.
The
P_PARAMETERSarray which is used to pass bind variables is anIN OUTparameter, soOUTparameters are passed back. -
-
(Optional) Retrieve the
OUTparameters. Walk through the variable of theAPEX_EXEC.T_PARAMETERStype and useGET_PARAMETER_VALUEto retrieve theOUTparameter value.
See Also:
For code examples of a complete remote procedure or REST API query, review the example sections in the following APIs: