-- Cleanup backup table after successful verification
-- This script is automatically called by install_mars1096.sql
-- Can also be run manually if needed
-- CRITICAL: Use ALL_TABLES when installing as ADMIN user

SET SERVEROUTPUT ON

DECLARE
    v_table_exists NUMBER := 0;
BEGIN
    SELECT COUNT(*) INTO v_table_exists
    FROM all_tables
    WHERE owner = 'CT_MRDS'
      AND table_name = 'A_PROCESS_LOG_OLD';

    IF v_table_exists > 0 THEN
        EXECUTE IMMEDIATE 'DROP TABLE CT_MRDS.A_PROCESS_LOG_OLD PURGE';
        DBMS_OUTPUT.PUT_LINE('Backup table A_PROCESS_LOG_OLD dropped successfully.');
    ELSE
        DBMS_OUTPUT.PUT_LINE('No backup table found. Nothing to clean up.');
    END IF;
END;
/
