diff --git a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 index 15580bdfe..241585547 100644 --- a/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 +++ b/ansible/roles/oracle-db-refresh/templates/get_latest_backup_control_file.sql.j2 @@ -1,12 +1,13 @@ set head off echo off feedback off spool /tmp/{{ ORACLE_DB_REFRESH_FILE }} with controlfile_details as - ( select db_key, max(completion_time) completion_time - from rcvcatowner.RC_BACKUP_CONTROLFILE - where db_name = '{{ ORACLE_DB_REFRESH_DB_NAME }}' group by db_key - ) -select a.HANDLE -from rcvcatowner.RC_BACKUP_PIECE a, controlfile_details b -where a.db_key =b.db_key -and a.completion_time=b.completion_time; +( + select db_key, max(stamp) stamp from rcvcatowner.rc_backup_controlfile + where autobackup_date is NULL and db_name = '{{ ORACLE_DB_REFRESH_DB_NAME }}' + group by db_key +) +select a.HANDLE from rcvcatowner.rc_backup_piece a, controlfile_details b, rcvcatowner.rc_backup_controlfile c +where a.db_key =b.db_key and a.stamp=b.stamp and a.stamp=c.stamp and a.db_key=c.db_key and a.set_stamp=c.set_stamp and a.bs_key=c.bs_key +/ + exit