I based this on some example I saw online.
Use it for column text as a CSV header row, combining rows of text into one column like customer comments or multiple email addresses assigned to a customer - typically with a pipe delimiter.
It's such a handy function.
select listagg(cast(column_text as varchar(64)), ' , ')
within group(order by ordinal_position) as coltext
where table_schema = < your lib >
and table_name = < your pf >
From: OpenSource <opensource-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Richard Schoen
Sent: Saturday, December 4, 2021 10:08 AM
Subject: Re: [IBMiOSS] Beginner Python Question about Db2 to Excel
Would love to see a sample of what you're describing.
date: Fri, 3 Dec 2021 23:47:45 +0000
from: Roger Harman <roger.harman@xxxxxxxxxxx>
subject: Re: [IBMiOSS] Beginner Python Question about Db2 to Excel
I do this all the time in DB2 SQL but I'm creating CSV's.
I use List_Agg() to get all the data from syscolumns in one CSV row. Our DB is standardized around the TEXT() info not COLHDG() but the concept would be similar.
You'll probably want to be sure to "order by ordinal_position" to get them in the right sequence.
I'll be interested in seeing the Python solution with COLHDG() and formatting them as multi-line headers in Excel.
COMMON Certified Application Developer - ILE RPG on IBM i on Power
As an Amazon Associate we earn from qualifying purchases.