Home > APEX_PLSQL_JOB > UPDATE_JOB_ST...
Previous |
Next |
Call this procedure to update the status of the currently running job. This procedure is most effective when called from the submitted PL/SQL.
Syntax
APEX_PLSQL_JOB.UPDATE_JOB_STATUS ( p_job IN NUMBER, p_status IN VARCHAR2);
Parameters
Table: UPDATE_JOB_STATUS Parameters describes the parameters available in the UPDATE_JOB_STATUS procedure.
UPDATE_JOB_STATUS Parameters
Parameter | Description |
---|---|
|
Passed the reserved word JOB. When this code is executed it will have visibility to the job number via the reserved word JOB. |
p_status |
Plain text that you want associated with
|
Example
The following example shows how to use the UPDATE_JOB_STATUS procedure. In this example, note that:
Lines 002 to 010 run a loop that inserts 100 records into the emp table.
APP_JOB
is referenced as a bind variable inside the VALUES
clause of the INSERT
, and specified as the p_job
parameter value in the call to UPDATE_JOB_STATUS
.
APP_JOB
represents the job number which will be assigned to this process as it is submitted to APEX_PLSQL_JOB
. By specifying this reserved item inside your process code, it will be replaced for you at execution time with the actual job number.
Note that this example calls to UPDATE_JOB_STATUS
every ten records, inside the block of code. Normally, Oracle transaction rules dictate updates made inside code blocks will not be seen until the entire transaction is committed. The APEX_PLSQL_JOB.UPDATE_JOB_STATUS
procedure, however, has been implemented in such a way that the update will happen regardless of whether or not the job succeeds or fails. This last point is important for two reasons:
Even if your status shows "100 rows inserted", it does not mean the entire operation was successful. If an error occurred at the time the block of code tried to commit, the user_status column of APEX_PLSQL_JOBS
would not be affected because status updates are committed separately.
Updates are performed autonomously. You can view the job status before the job has completed. This gives you the ability to display status text about ongoing operations in the background as they are happening.
BEGIN FOR i IN 1 .. 100 LOOP INSERT INTO emp(a,b) VALUES (:APP_JOB,i); IF MOD(i,10) = 0 THEN APEX_PLSQL_JOB.UPDATE_JOB_STATUS( P_JOB => :APP_JOB, P_STATUS => i || ' rows inserted'); END IF; APEX_UTIL.PAUSE(2); END LOOP; END;