I am using Oracle APEX 22.1.4 and I am trying to invoke automatic row processing (DML) process programmatically.
I tried as follows but it doesn't work.
apex.server.process(
'SAVE_PERSON', // Specify your process name here
{
},
{
request: 'UPDATE', // Specify the DML operation (CREATE, UPDATE, DELETE, etc.)
dataType: 'text', // Ensure the response type is handled correctly
success: function(data) {
console.log('DML operation executed successfully: ' + data);
},
error: function(xhr, textStatus, errorThrown) {
console.error('Error executing DML operation:', errorThrown);
}
}
);
Can anybody suggest an idea to achieve this?
First of all, to have a custom process on your page, you either need a form region or a Interactive grid:
Form - Automatic Row Processing (DML)
Process to insert, update, or delete a form region row(s).
Interactive Grid - Automatic Row Processing (DML)
Process to insert, update, or delete Interactive Grid rows.
Second point you need to consider is the Syntax: As Help section on the page suggests:
begin
case :APEX$ROW_STATUS
when 'C' then
insert into emp ( empno, ename, deptno )
values ( :P1_EMPNO, :P1_ENAME, :P1_DEPTNO )
returning rowid into :P1_ROWID;
when 'U' then
update emp
set ename = :P1_ENAME,
deptno = :P1_DEPTNO
where rowid = :P1_ROWID;
when 'D' then
delete emp
where rowid = :P1_ROWID;
end case;
end;
You need to use this format to have a custom code as DML. The example code you are using in you question, is an example of AJAX callback Javascript function
** You of course need to modify the code and conditions for your use-case. This is just a simple example of how the PL/SQL code should be structured for custom DML.