Automatic Refresh Of A Page Region
EEGOct 21 2007 — edited Nov 5 2007Hello All.
I am working on an Apex 2.2.1 application in which the requirement is to have a report residing in a specific region on a page automatically refresh with the latest batch of rows that is being inserted into an Oracle table. The report needs to refresh showing the latest set of inserted rows every second.
The data rows are being continuously (24x7) inserted into a table via a PRO*C
application I wrote that is feeding data coming from electronic sensors.
The user does not want to manually refresh the page but rather have a specific report region on the page automatically display the latest set (as of 1 second ago) of newly inserted rows, similar to what is commonly done with a stock ticker on a web page that automatically displays the latest stock prices in near real time.
I am thinking (have not done it) of using Oracle's Change Data Capture (CDC) in combination with DBMS_SCHEDULER to capture the newly inserted rows (as of the last refresh which, in my case, would be as of 1 second ago) and then have the Apex report region select from the CDC change table all of the "captured" rows.
I would create a button on my Apex page that, when clicked, would call the DBMS_SCHEDULER procedure to create a job scheduled to run every 1 second. This job would run the CDC procedure DBMS_CDC_SUBSCRIBE.EXTEND_WINDOW to capture the next set of newly created rows, if any. The report should then automatically display these captured rows. Then the job I created via DBMS_SCHEDULER would run again after 1 second to capture the next set of rows. And the report should once again "refresh" and display these rows from the underlying change table.
I am thinking this is a good way to implement such an automatic refresh of the report region to display the latest (as of 1 second ago) set of newly created data rows.
I have two questions about all this.
1) Does this workflow sound OK to you? Would someone know of a better way
to accomplish the above goal?
2) In whatever way I end up using, I am not sure how to go about **automatically** refreshing the report region. Does someone know how to go about doing this?
I have been reading about AJAX and have recently received help from Carl Backstrom on this Forum with another question that involves AJAX but am still
an AJAX newbie, and so, am wondering if AJAX would help me here.
Thank you all in advance for any help/advice. It is much appreciated.
Elie