13.5.1.2.3 Deleting a REST Source Row in Code
Review an example of deleting a row from a REST Data Source.
A simple example that deletes one employee from the Employees (Simple HTTP)
REST Data Source is below. Notice the code references the REST Data Source using its
Static ID employees_simple_http and that it only needs to define the
primary key column since the corresponding operation for the Delete row database
action has no payload containing attribute values.
declare
l_cols apex_exec.t_columns;
l_dml_ctx apex_exec.t_context;
begin
apex_exec.add_column(
p_columns => l_cols,
p_column_name => 'EMPNO',
p_data_type => apex_exec.c_data_type_number,
p_is_primary_key => true);
l_dml_ctx := apex_exec.open_rest_source_dml_context(
p_static_id => 'employees_simple_http',
p_columns => l_cols);
-- Delete SMITH
apex_exec.add_dml_row(l_dml_ctx,apex_exec.c_dml_operation_delete);
apex_exec.set_value(l_dml_ctx,'EMPNO',7369);
-- Process the DML context
apex_exec.execute_dml(l_dml_ctx);
apex_exec.close(l_dml_ctx);
exception
when others then
apex_exec.close(l_dml_ctx);
raise;
end;Parent topic: Modifying REST Source Rows in Code