Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Create XML file using Oracle SQL 19c

JonkOct 24 2023

Hi Community Members,

I need help in generating an XML file from Oracle 19c. The data I'm working with consists of one header record that can contain multiple detail records. The number of detail records can vary from one to as many as 100s. My goal is to convert this data into an XML file. Here's an example of the data:

with sample_data
(DOC_CAT, DOC_TYP, DOC_CD, DOC_DEPT, DOC_ID, DOC_VERS_NO, LINE_NO, DOC_UNIT, EMPID, HOME_DEPT, EFFECTIVE_DT, PAY_TYPE, LINE_AM, PAY_RT_AM)
as
(select 'TLM', 'ADJ', 'ADJX', 'HR', 'HR001', '1', '1', null, '100', 'HR', to_date('09232023','mmddyyyy'), '733', '8:00', 35.55 from dual union all
select 'TLM', 'ADJ', 'ADJX', 'HR', 'HR001', '1', '2', null, '100', 'HR', to_date('09302023','mmddyyyy'), '733', '12:00', 40.58 from dual union all
select 'TLM', 'ADJ', 'ADJX', 'MKT', 'MKT100', '1', '1', 'MKT101', '200', 'MKT', to_date('09202023','mmddyyyy'), '700', '31:00', 20.45 from dual
)
select * from sample_data

Thank you,
Jonk

Comments
Post Details
Added on Oct 24 2023
6 comments
732 views