Skip to Main Content
  • Questions
  • PAGE REFRESH CAUSED BY DATABASE TRIGGER.

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Prince.

Asked: January 06, 2026 - 2:37 pm UTC

Last updated: January 08, 2026 - 7:53 am UTC

Version: 24.2

Viewed 100+ times

You Asked

Hi,
I have created an application that is tracking a set of processes that are being run from a master table. When a process is completed, a flag in a column name PROC_EXEC_STATUS changes from N to Y for each process. I want my oracle apex application to refresh when the flag for the each individual processes in the table is updated. I have used javascript but then because the processes do not have a defined running time, it just continues to refresh and sometimes is not in sync with the process running time. I am on apex version 24.2.

and Connor said...

An AJAX call could be done for this.

Let's say your table looks like this:

SQL> create table process_status ( pname varchar2(10), s varchar2(1));

Table created.

SQL> insert into process_status values ('P1','N');

1 row created.

SQL> insert into process_status values ('P2','N');

1 row created.

SQL> insert into process_status values ('P3','N');

1 row created.

SQL> select * from process_status;

PNAME      S
---------- -
P1         N
P2         N
P3         N


In APEX, lets say page 1 is your region that you want to refresh when the status of any these changes, and the region has a static ID of "my_region"

1) Add an item P1_OVERALL_STATUS as hidden. This will hold the status of the processes, eg "NNN" to represent the initial state above. "YNN" when process 1 starts etc. Give it a default value of "X" so we will always do an initial refresh

2) Add an AJAX callback called (say) "CHECK_CHANGES" with some code like the following:

begin
    apex_json.open_object;

    for r in (
        select 'STATUS' tag, listagg(s) within group ( order by pname) as status from process_status;
    ) loop
        apex_json.write(
            p_name  => r.tag,
            p_value => r.status
        );
    end loop;

    apex_json.close_object;
end;


3) Add some JS to the page to use the AJAX callback to decide if you need a refresh

function checkForChanges() {
    apex.server.process(
        "CHECK_CHANGES",
        {},
        {
            dataType: "json",
            success: function (data) {

                if (data.STATUS !== $v("P1_OVERALL_STATUS ")) {
                    $s("P1_OVERALL_STATUS ", data.STATUS);
                    apex.region("my_region").refresh();
                }

            }
        }
    );
}

setInterval(checkForChanges, 10000);


In this case, every 10 seconds we'll compare the process state in the table to that in the hidden item, and refresh the region if needed.