-- ============================================================================
-- MARS-826 Export Step 05: MRR_IND_CURR_ACC Tables
-- ============================================================================
-- Purpose: Export MRR_IND_CURR_ACC table group to HIST bucket
-- Author: Grzegorz Michalski
-- Schema: OU_MRR (different from other groups)
-- Tables: 2 tables
-- Target: mrds_hist_dev/ARCHIVE/LM/LM_CURRENT_ACCOUNTS_*
-- ============================================================================

SET SERVEROUTPUT ON SIZE UNLIMITED

PROMPT
PROMPT ============================================================================
PROMPT Step 05: Exporting MRR_IND_CURR_ACC Tables (2 tables from OU_MRR schema)
PROMPT ============================================================================

-- Table 1: LEGACY_MRR_IND_CURRENT_ACCOUNT_HEADER
PROMPT
PROMPT Exporting OU_MRR.LEGACY_MRR_IND_CURRENT_ACCOUNT_HEADER...
BEGIN
    CT_MRDS.DATA_EXPORTER.EXPORT_TABLE_DATA_BY_DATE(
        pSchemaName => 'OU_MRR',
        pTableName => 'LEGACY_MRR_IND_CURRENT_ACCOUNT_HEADER',
        pKeyColumnName => 'A_ETL_LOAD_SET_KEY',
        pBucketArea => 'ARCHIVE',
        pFolderName => 'ARCHIVE/LM/LM_CURRENT_ACCOUNTS_HEADER',
        pParallelDegree => 2,
        pTemplateTableName => 'CT_ET_TEMPLATES.LM_CURRENT_ACCOUNTS_HEADER',
        pJobClass => 'high'
    );
    DBMS_OUTPUT.PUT_LINE('SUCCESS: LEGACY_MRR_IND_CURRENT_ACCOUNT_HEADER exported');
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR exporting MRR_IND_CURRENT_ACCOUNT_HEADER: ' || SQLERRM);
        RAISE;
END;
/

-- Table 2: LEGACY_MRR_IND_CURRENT_ACCOUNT_ITEM
PROMPT
PROMPT Exporting OU_MRR.LEGACY_MRR_IND_CURRENT_ACCOUNT_ITEM...
BEGIN
    CT_MRDS.DATA_EXPORTER.EXPORT_TABLE_DATA_BY_DATE(
        pSchemaName => 'OU_MRR',
        pTableName => 'LEGACY_MRR_IND_CURRENT_ACCOUNT_ITEM',
        pKeyColumnName => 'A_ETL_LOAD_SET_KEY',
        pBucketArea => 'ARCHIVE',
        pFolderName => 'ARCHIVE/LM/LM_CURRENT_ACCOUNTS_ITEM',
        pParallelDegree => 16,
        pTemplateTableName => 'CT_ET_TEMPLATES.LM_CURRENT_ACCOUNTS_ITEM',
        pJobClass => 'high'
    );
    DBMS_OUTPUT.PUT_LINE('SUCCESS: LEGACY_MRR_IND_CURRENT_ACCOUNT_ITEM exported');
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR exporting MRR_IND_CURRENT_ACCOUNT_ITEM: ' || SQLERRM);
        RAISE;
END;
/

PROMPT
PROMPT Step 05 completed: All MRR_IND_CURRENT_ACCOUNT tables exported
PROMPT
