MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BMC Unload

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
shreyas_e
Beginner


Joined: 06 Nov 2017
Posts: 10
Topics: 4

PostPosted: Wed May 29, 2019 2:23 pm    Post subject: BMC Unload Reply with quote

Hi, We are working on a project to unload DB2 data into a file and FTP it to AWS S3. I am running the BMC Unload utility(ADUUMAIN) now and it works fine and extracts the data in CSV format. However, I also need to have column names in the extract. Is there option in BMC Unload that does extract column names also?
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed May 29, 2019 5:54 pm    Post subject: Reply with quote

You could unload them from the relevant catalog table.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Wed May 29, 2019 9:29 pm    Post subject: Re: BMC Unload Reply with quote

shreyas_e wrote:
Hi, We are working on a project to unload DB2 data into a file and FTP it to AWS S3. I am running the BMC Unload utility(ADUUMAIN) now and it works fine and extracts the data in CSV format. However, I also need to have column names in the extract. Is there option in BMC Unload that does extract column names also?


You can add column names as headers with adding another SQL

something like this (untested)
Code:

SELECT 'Column_Name1'
      ,'Column_Name2'
      ,'Column_Name3'
....
FROM SYSIBM.SYSDUMMY1 WITH UR;


If you want to automate this procedure, then as NIC pointed out you can retrieve the Column Names from the catalog table SYSIBM.SYSCOLUMNS

something like this

Code:

SELECT A.COL_NAME                                               
  FROM (SELECT SUBSTR(CHAR(CASE                                 
                      WHEN COLNO        = 1                     
                      THEN CHAR('SELECT CHAR(')                ||
                           CHAR('''')                          ||
                           SUBSTR(NAME,1,LENGTH(RTRIM(NAME)))  ||
                           CHAR(',')                           ||
                           CHAR('''')                          ||
                           CHAR(')')                             
                      WHEN COLNO        > 1                     
                      THEN CHAR('      ,CHAR(')                ||
                           CHAR('''')                          ||
                           SUBSTR(NAME,1,LENGTH(RTRIM(NAME)))  ||
                           CHAR(',')                           ||
                           CHAR('''')                          ||
                           CHAR(')')                             
                       END),1,80)                 AS COL_NAME   
              ,COLNO                              AS COL_NO     
  FROM SYSIBM.SYSCOLUMNS                                         
 WHERE TBNAME = 'your_table_name'                                   
 UNION                                                           
SELECT B.COL_NAME                                               
      ,B.COL_NO                                                 
  FROM (SELECT CHAR('  FROM SYSIBM.SYSDUMMY1'                  ||
                     '  WITH UR;')                AS COL_NAME   
               ,MAX(COLNO) + 1                    AS COL_NO     
          FROM SYSIBM.SYSCOLUMNS                                 
         WHERE TBNAME = 'your_table_name') B) A                     
  ORDER BY A.COL_NO                                             
;

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shreyas_e
Beginner


Joined: 06 Nov 2017
Posts: 10
Topics: 4

PostPosted: Thu May 30, 2019 4:38 pm    Post subject: Reply with quote

Thanks Nic and Kolusu
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group