-- ============================================================================
-- MARS-1409 Step 08: Install TRG_A_WORKFLOW_HISTORY trigger
-- ============================================================================
-- Purpose: Update trigger to mark A_SOURCE_FILE_RECEIVED as INGESTED
--          when WORKFLOW_SUCCESSFUL is set to 'Y'
-- ============================================================================

PROMPT Installing TRG_A_WORKFLOW_HISTORY (new_version)...
@@new_version/TRG_A_WORKFLOW_HISTORY.sql

PROMPT
DECLARE
    v_status VARCHAR2(20);
BEGIN
    SELECT status INTO v_status
    FROM all_objects
    WHERE owner = 'CT_MRDS'
      AND object_name = 'TRG_A_WORKFLOW_HISTORY'
      AND object_type = 'TRIGGER';
    DBMS_OUTPUT.PUT_LINE('TRG_A_WORKFLOW_HISTORY status: ' || v_status);
EXCEPTION
    WHEN NO_DATA_FOUND THEN
        RAISE_APPLICATION_ERROR(-20001, 'ERROR: TRG_A_WORKFLOW_HISTORY not found after installation');
END;
/
