Getting SQL Query column names as variable

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
If you need a quicker response, please create a support ticket via the customer portal my.goanywhere.com or contact our support team by email at [email protected].
2 posts Page 1 of 1

john_a

Posts: 9
Joined: Tue Nov 03, 2015 5:35 pm

Post by john_a » Mon Nov 09, 2015 8:51 pm
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.

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Nov 10, 2015 9:51 am
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.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1