Page 1 of 1

Getting SQL Query column names as variable

Posted: Mon Nov 09, 2015 8:51 pm
by john_a
Hi all, I am dealing with a DB2 table that has a large number of columns what would be nice to do is get a dump of the data from a table into either a CSV or an XML file with the column names included. Is there an easy way to do this.

If I cannot do that can I get the column names as collection of data so that the index of the collection matches its prospective value.

So,for instance --

${colName[3]} = 'Addr1'
${data[3]} = '90210 Mulholland Dr.'

So that if I do a SELECT * on the table and I can get a count of the fields it is a simple matter to do a data dump of the table.

Re: Getting SQL Query column names as variable

Posted: Tue Nov 10, 2015 9:51 am
by Support_Rick
John,

You can do an SQL Select of your data from the DB2 Table, creating a rowset variable. Use that rowset variable to create (writeCSV) a CSV file. After defining the input from the Select Statement and giving it a file name to create, go to the Advanced Tab and change the "Include Column Headings" to true.

This will give you a CSV file with the 1st row being the Column Headings for each row.