I received an e-mail from a reader asking an interesting question. She wanted to know if any of the DB2 unload utilities are able to include the column names in the same file as the unload output data. This was a requirement because one of the applications her company was planning to use takes the column headings and dynamically creates tables.
My initial reaction was that she could write a program that takes the output file and reads the system catalog to gather the appropriate column names. That would work, but she actually came up with a better solution.
She used a third party Unload utility (but it would also have worked with IBM’s Unload, too) to perform two SELECT statements. The first just creates the column headers and the second for the actual data. The column names and data go to two separate data sets, but they used IDCAMS to concatenate the 2 separate column/data sets into 1 data set.
The SQL is simple, something like as follows:
SELECT 'COLUMN NAME 1', 'COLUMN NAME 2', 'COLUMN NAME 3', 'COLUMN NAME 4' FROM SYSIBM.SYSDUMMY1 SELECT COL1, COL2, COL3, COL4 FROM XXXXXX.TABLE1
Of course, you’d just plug in the correct column names in the literals of the first SELECT statement — and the correct column names in the second.
This post was originally posted on Craig Mullins’ blog.
EPM applications help measure the business performance. This post will help you choose the best EPM solutions for your organization’s needs and objectives.
Imagine there are over one hundred logins in the source server and you need to migrate them all over to the destination server. Wouldn’t it be awesome if we could automate the process by generating the scripts for the required tasks?