Thursday, 17 July 2014

Query to Generate XML Data Node in Oracle Apps

/* Formatted on 7/17/2014 5:40:14 PM (QP5 v5.115.810.9015) */
SELECT LPAD (' ', 13 * 1, ' ') || a
FROM (SELECT *
      FROM (SELECT ', ( SELECT XMLElement' a, 'A01'
            FROM DUAL
            UNION
            SELECT '           ( "-List"', 'A02'
            FROM DUAL
            UNION
            SELECT '           , XMLAgg', 'A03'
            FROM DUAL
            UNION
            SELECT '             ( XMLElement', 'A04'
            FROM DUAL
            UNION
            SELECT '               ( "-"', 'A05'
            FROM DUAL
            UNION
            SELECT '               , XMLAttributes', 'A06'
            FROM DUAL
            UNION
            SELECT '                 ( class_code as "-ID"', 'A07'
            FROM DUAL
            UNION
            SELECT '                 ) ', 'A08'
            FROM DUAL
            UNION
            SELECT '                 , XMLElement', 'A09'
            FROM DUAL
            UNION
            SELECT '                   ( "-Details"', 'A10'
            FROM DUAL
            UNION
            SELECT '                   , XMLforest', 'A11'
            FROM DUAL
            UNION
            SELECT '                     (' a, 'A12'
            FROM DUAL
            UNION
            SELECT *
            FROM (SELECT    LPAD (', ', 24, ' ')
                         || RPAD (column_name, 30, ' ')
                         || ' as "'
                         || REPLACE (INITCAP (REPLACE (column_name, '_', ' ')),
                                     ' '
                            )
                         || '"'
                            b,
                         'B' || column_name
                  FROM dba_tab_columns
                  WHERE table_name = UPPER ('ap_pay_group'))
            UNION
            SELECT '                     )', 'C01'
            FROM DUAL
            UNION
            SELECT '                   )', 'C02'
            FROM DUAL
            UNION
            SELECT '               )', 'C03'
            FROM DUAL
            UNION
            SELECT '             )', 'C04'
            FROM DUAL
            UNION
            SELECT '           )', 'C05'
            FROM DUAL
            UNION
            SELECT '      from ap_pay_group apg ', 'C06'
            FROM DUAL
            UNION
            SELECT '     where apg.checkrun_id = isc.checkrun_id ', 'C07'
            FROM DUAL
            UNION
            SELECT '  )', 'C08'
            FROM DUAL)
      ORDER BY 2)

No comments:

Post a Comment