Skip to content

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].
  • john_a Offline
  • Posts: 9
  • Joined: Tue Nov 03, 2015 5:35 pm

Getting SQL Query column names as variable

Post 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.
  • Support_Rick Offline
  • Support Specialist
  • Posts: 590
  • Joined: Tue Jul 17, 2012 2:12 pm
  • Location: Phoenix, AZ
  • Contact:

Re: Getting SQL Query column names as variable

Post 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.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Post Reply