33.31 PARSE_REFETCH_RESPONSEファンクション
このファンクションは、DML行の再フェッチからのレスポンスを解析します。行の再フェッチは、他のユーザーが行を変更していないことを確認するために、失われた更新の検出に使用されます。このファンクションを使用するには、RESTデータ・ソースに単一行のフェッチのデータベース操作が定義されている必要があります。
構文
APEX_PLUGIN_UTIL.PARSE_REFETCH_RESPONSE (
p_web_source_operation IN wwv_flow_plugin_api.t_web_source_operation,
p_web_source IN wwv_flow_plugin_api.t_web_source,
p_values_context IN wwv_flow_exec_api.t_context,
--
p_response IN CLOB )
RETURN wwv_flow_exec_api.t_context;
パラメータ
表33-47 PARSE_REFETCH_RESPONSEのパラメータ
パラメータ | 説明 |
---|---|
p_web_source_operation |
RESTデータ・ソース操作(プラグイン)のメタデータ |
p_web_source |
RESTデータ・ソース(プラグイン)のメタデータ |
p_response |
解析するRESTレスポンス |
p_values_context |
DML列定義に必要な値コンテキスト |
戻り値
表33-48 PARSE_REFETCH_RESPONSEの戻り値
パラメータ | 説明 |
---|---|
|
プラグイン開発者がチェックサムまたは列値を取得するための、 |
例
次の例では、更新する特定の行に対してプラグインDMLファンクション内で再フェッチ操作を実行し、失われた更新を検出するためにチェックサムを比較する方法を示します。
apex_plugin_util.parse_refetch_response (
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 => wwv_flow_plugin_api.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"
wwv_flow_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 := wwv_flow_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_exec.next_row( p_context => l_refetch_context ) THEN
l_checksum := apex_exec.get_row_version_checksum( p_context => p_params.update_values_context );
l_refetched_checksum := apex_exec.get_row_version_checksum( p_context => l_refetch_context );
IF l_checksum != l_refetched_checksum THEN
apex_exec.set_row_status(
p_context => p_result.update_values_context,
p_sqlcode => -20987,
p_sqlerrm => 'APEX.DATA_HAS_CHANGED' );
END IF;
END IF;
END IF;
-- continue with DML logic here ...
END plugin_dml;
親トピック: APEX_PLUGIN_UTIL