45.3 CURRENT_ROW_CHANGED Function
This function determines whether the current row changed between the two contexts. In order to compare the next row within the value context, use APEX_EXEC.NEXT_ROW
for both contexts.
Syntax
API_PLUGIN_UTIL.CURRENT_ROW_CHANGED(
p_old_row_context IN apex_exec.t_context,
p_new_row_context IN apex_exec.t_context )
RETURN BOOLEAN;
Parameters
Parameter | Description |
---|---|
p_old_row_context |
Values context containing values before the change. |
p_new_row_context |
Values context containing values after the change. |
Returns
Parameter | Description |
---|---|
* |
Whether there is a difference between the rows. |
Example
The following example performs a "refetch" operation within the Plug-In DML function for a given row to be updated and check whether the row would actually be changed with the DML operation. If not, we could suppress the HTTP request.
procedure plugin_dml(
p_plugin in apex_plugin.t_plugin,
p_web_source in apex_plugin.t_web_source,
p_params in apex_plugin.t_web_source_dml_params,
p_result in out nocopy apex_plugin.t_web_source_dml_result )
IS
l_web_source_operation apex_plugin.t_web_source_operation;
l_request_body clob;
l_response clob;
l_refetch_context apex_exec.t_context;
l_checksum varchar2(32767);
l_refetched_checksum varchar2(32767);
BEGIN
p_result.update_values_context := p_params.update_values_context;
--
-- this code performs a "refetch" operation for a row, in order to perform
-- lost update detection. This happens before the actual DML.
--
IF p_web_source.operations.exists( apex_plugin.c_db_operation_fetch_row ) THEN
l_web_source_operation := apex_plugin_util.get_web_source_operation(
p_web_source => p_web_source,
p_db_operation => apex_plugin.c_db_operation_fetch_row,
p_preserve_headers => false,
p_perform_init => true );
-- add some logic to add primary key values to the URL or as HTTP headers here
-- PK values can be obtained from "p_params.update_values_context"
apex_plugin_util.make_rest_request(
p_web_source_operation => l_web_source_operation,
p_request_body => l_request_body,
p_response => l_response,
p_response_parameters => p_result.out_parameters );
l_refetch_context := apex_plugin_util.parse_refetch_response(
p_web_source_operation => l_web_source_operation,
p_web_source => p_web_source,
p_response => l_response,
p_values_context => p_params.update_values_context );
IF apex_plugin_util.current_row_changed(
p_old_row_context => l_refetch_context,
p_new_row_context => p_params.update_values_context )
THEN
-- perform actual DML here
--
ELSE
apex_exec.set_row_status(
p_context => p_result.update_values_context,
p_sqlcode => 0,
p_sqlerrm => 'SKIPPED' );
END IF;
END IF;
END plugin_dml;
Parent topic: APEX_PLUGIN_UTIL