-- ============================================================================
-- MARS-826 Export Step 08: TTS Tables
-- ============================================================================
-- Purpose: Export TTS table group to HIST bucket
-- Author: Grzegorz Michalski
-- Tables: 2 tables (~1,120 records total)
-- Target: mrds_hist_dev/ARCHIVE/LM/LM_TTS_*
-- ============================================================================

SET SERVEROUTPUT ON SIZE UNLIMITED

PROMPT
PROMPT ============================================================================
PROMPT Step 08: Exporting TTS Tables (2 tables)
PROMPT ============================================================================

-- Table 1: LEGACY_TTS_HEADER (~560 records)
PROMPT
PROMPT Exporting OU_LM.LEGACY_TTS_HEADER...
BEGIN
    CT_MRDS.DATA_EXPORTER.EXPORT_TABLE_DATA_BY_DATE(
        pSchemaName => 'OU_LM',
        pTableName => 'LEGACY_TTS_HEADER',
        pKeyColumnName => 'A_ETL_LOAD_SET_FK',
        pBucketArea => 'ARCHIVE',
        pFolderName => 'ARCHIVE/LM/LM_TTS_HEADER',
        pParallelDegree => 1,
        pTemplateTableName => 'CT_ET_TEMPLATES.LM_TTS_HEADER',
        pJobClass => 'high'
    );
    DBMS_OUTPUT.PUT_LINE('SUCCESS: LEGACY_TTS_HEADER exported');
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR exporting TTS_HEADER: ' || SQLERRM);
        RAISE;
END;
/

-- Table 2: LEGACY_TTS_ITEM (~560 records)
PROMPT
PROMPT Exporting OU_LM.LEGACY_TTS_ITEM...
BEGIN
    CT_MRDS.DATA_EXPORTER.EXPORT_TABLE_DATA_BY_DATE(
        pSchemaName => 'OU_LM',
        pTableName => 'LEGACY_TTS_ITEM',
        pKeyColumnName => 'A_ETL_LOAD_SET_FK',
        pBucketArea => 'ARCHIVE',
        pFolderName => 'ARCHIVE/LM/LM_TTS_ITEM',
        pParallelDegree => 1,
        pTemplateTableName => 'CT_ET_TEMPLATES.LM_TTS_ITEM',
        pJobClass => 'high'
    );
    DBMS_OUTPUT.PUT_LINE('SUCCESS: LEGACY_TTS_ITEM exported');
EXCEPTION
    WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE('ERROR exporting TTS_ITEM: ' || SQLERRM);
        RAISE;
END;
/

PROMPT
PROMPT Step 08 completed: All TTS tables exported
PROMPT
