-- Time difference between primary and standby database
set serveroutput on;
DECLARE
v_diff NUMBER := 0;
v_hrs NUMBER := 0;
v_min NUMBER := 0;
v_sec NUMBER := 0;
p_dte1 DATE;
p_dte2 DATE;
date1 long;
date2 long;
BEGIN
date1 := 'select sysdate from dual';
date2 := 'select max(TIMESTAMP) from v$recovery_progress';
execute immediate date1 into p_dte1;
execute immediate date2 into p_dte2;
v_diff := ABS(p_dte2 - p_dte1);
v_hrs := TRUNC(v_diff, 0)*24;
v_diff := (v_diff - TRUNC(v_diff, 0))*24;
v_hrs := v_hrs + TRUNC(v_diff, 0);
v_diff := (v_diff - TRUNC(v_diff, 0))*60;
v_min := TRUNC(v_diff, 0);
v_sec := TRUNC((v_diff - TRUNC(v_diff, 0))*60, 0);
DBMS_OUTPUT.put_line(
TO_CHAR(v_hrs) ||' '||
TO_CHAR(v_min) ||' '||
TO_CHAR(v_sec) );
END;
/
No comments:
Post a Comment