Simple Apex Apps using REST Data Services

Create Modulemodule.JPG

Create Template

template

Create Handler

handler

Following query will return RMAN Backup Duration in seconds format for latest RMAN job


with backup_runs as
(
select
    operation,
    status,
    object_type,
    start_time,
    end_time,
    to_char(start_time,'MM/DD/YYYY HH24:MI:SS') as char_start_time,
    to_char(end_time,'MM/DD/YYYY HH24:MI:SS') as char_end_time
from
    v$rman_status
where 
	operation in ('RMAN','BACKUP')
and 	
	OBJECT_TYPE like '%DB%'
and 
    STATUS = 'COMPLETED'
 and start_time = ( select max(inner.start_time) from v$rman_status inner where operation in ('RMAN','BACKUP')
and 	
	OBJECT_TYPE like '%DB%'
and 
    STATUS = 'COMPLETED')    

)

select 
    char_start_time as "Backup Start Time",
    char_end_time as "Backup End time",
    round((select 86400* (end_time - start_time) difference_in_hours from dual)) as "Backup Job Duration in Seconds"
from backup_runs

Full URL would return the following

{“items”:[{“backup_start_time”:”11/07/2018 08:25:15″,”backup_end_time”:”11/07/2018 10:52:48″,”backup_job_duration_in_seconds”:8853}],”first”:{“$ref”:”http://tomcat-host:8001/ords_appadt/services/latestBackup/backupTime”}}

In APEX Application, Region →  Source


      $.getJSON(         'http://tomcat-host:8001/ords_appadt/services/latestBackup/backupTime'         , function(data) {               var output = "";               output += "";                                 for (var i in data.items) {                     output += "";                 }             document.getElementById("adt_ltstbkp").innerHTML=output;         })

 

APEX

 

END

Leave a comment

";                     output += "Most Recent Backup";                     output += "
"                     + data.items[i].backup_start_time                     + "

"                     + data.items[i].backup_end_time                     + "

"                     + "

"                     + "Duration (sec) :"                     + data.items[i].backup_job_duration_in_seconds                     + "

"                     + "