Finding DB2 table length through REXX

Time Sharing Option, Interactive System Productivity Facility and REstructured eXtended eXecutor

Moderator: mickeydusaor

Post Reply
vinoth4u
New Member
Posts: 6
Joined: Fri Aug 14, 2015 3:37 pm

Finding DB2 table length through REXX

Post by vinoth4u »

Hello All,

I am doing REXX code to unload data from the DB2 table.Hence i need to know the length of the table so that the unloaded data will fit exactly into the output file.

Could someone please help me on how to find out the length of the input table given by user ?


Thanks & Regards,
Vinoth KM
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Finding DB2 table length through REXX

Post by nicc »

If you want help it will improve your chances if you post a rexx question in the rexx part of the forum and not in the cobol part! I have moved it for you.

What do you mean by 'length of the table'? The number of rows (query the table first using the COUNT facility)? Or something else?
What do you mean 'fit exactly into the output file'? it is a dataset not a file. Datasets can expand, through secondary allocation, or contract, through RLSE parameter, as required.
How are you doing the unload? Via a DB2 utility called by your Rexx program?
Regards
Nic
vinoth4u
New Member
Posts: 6
Joined: Fri Aug 14, 2015 3:37 pm

Re: Finding DB2 table length through REXX

Post by vinoth4u »

"Datasets can expand, through secondary allocation, or contract, through RLSE parameter" helps me to achieve what i want .Thanks Nicc

Thanks & Regards,
Vinoth KM
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: Finding DB2 table length through REXX

Post by Anuj Dhawan »

Hi Vinoth,

What are you using to unload the DB2 Table - is it DSNTIAUL or some unload utility available at your shop? Are you using DSNREXX to get connected with DB2 or you've a JCL which is executed using REXX?

If you are using DSNTIAUL and calling it using REXX, you can use the below JCL. You can notice that you can remove the LRECL for SYSREC00 DD. This can be taken care by DSNTIAUL itself. (In the JCL below, you've to replace xxxx with appropriate values for your shop).

Code: Select all

//UNLOAD  EXEC PGM=IKJEFT01,DYNAMNBR=20                   
//SYSTSPRT DD  SYSOUT=*                                   
//SYSTSIN  DD  *                                          
DSN SYSTEM(xxxx)                                          
RUN  PROGRAM(DSNTIAUL) PLAN(xxxx) -                   
     PARMS('SQL') LIB('xxxx')               
/*
//SYSPRINT DD SYSOUT=*                                    
//SYSUDUMP DD SYSOUT=*                                    
//*
//* Table Unload
//SYSREC00 DD DSN=USERID.TABLE.UNLOAD,                        
//            UNIT=SYSDA,                                  
//            DISP=(NEW,CATLG,DELETE),                              
//*
//SYSPUNCH DD DSN=USERID.SYSPUNCH,                        
//            UNIT=SYSDA,                                 
//            SPACE=(xxxx,(xxxx,xxxx)), 
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920),     
//            DISP=(NEW,CATLG,CATLG)                     
//SYSIN    DD *                                          
           SELECT *
           FROM  TABLE_NAME
           WITH UR;
/*
//*
On the other hand if you show us the REXX you are using, there might be better chances to understand what exactly might work in your case.
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
vinoth4u
New Member
Posts: 6
Joined: Fri Aug 14, 2015 3:37 pm

Re: Finding DB2 table length through REXX

Post by vinoth4u »

Hi Anuj,

Thanks a lot for your clear explanation. :D :D

Yeah,I am using "DSNTIAUL" and i have removed LRECL from the SYSREC00 and i am good now.


Thanks & Regards,
Vinoth KM
User avatar
DB2 Guy
Forum Moderator
Forum Moderator
Posts: 120
Joined: Sun Apr 21, 2013 8:25 pm
India

Re: Finding DB2 table length through REXX

Post by DB2 Guy »

Can you share your solution for the benefit of others. I am not sure what exactly worked for you as what Nic said and what Anuj has said, are two very different arguments.
vinoth4u
New Member
Posts: 6
Joined: Fri Aug 14, 2015 3:37 pm

Re: Finding DB2 table length through REXX

Post by vinoth4u »

Actually my intention in the tool is,

i. User needs to type the "table name & where clause columns" as per their requirement .
ii. Once they done,REXX will take care of unloading the data in the output file and it will be given to the USER.

Here i got the below confusion

1. How jcl knows the LRECL of different tables specified by the USER ?
Anuj clarified the above with "DSNTIAUL".

"If you are using DSNTIAUL and calling it using REXX. You can notice that you can remove the LRECL for SYSREC00 DD.
This can be taken care by DSNTIAUL itself"

Hope this clarifies !! :)

Thanks & Regards,
Vinoth KM
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “TSO, ISPF & REXX (Do you still do CLIST?!).”