View previous topic :: View next topic |
Author |
Message |
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Fri Aug 28, 2015 4:42 am Post subject: DB2 unload , reformat and load |
|
|
Hi
Employee table contains - EMP-NO Integer, DOJ DATE, DATE-REL DATE, SAL DECIMAL(9,2)
I want to unload the data from the above table and reformat the data and load the data to another table.
Want to reformat the data such that new field EXP INT has to be calculated ( difference of DOJ and current date. And new field BONUS DECIMAL(9,2) has to be added based on years of EXP field. IF EXP < 2 THEN 100000 otherwise 200000
Reformatted data is like this: EMPNO, DOJ, SAL,BONUS
Load reformatted data into another table with fields:
EMPNO INTEGER, DOJ DATE, SAL DECIMAL(9,2),BONUS DECIMAL(9,2)
Question is what is the unload jcl and load jcl used so that data can be modified and loaded back ?
Thanks |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Aug 28, 2015 5:50 am Post subject: |
|
|
Why unload? Why not INSERT into new table values (SELECT from old table)? _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Fri Aug 28, 2015 6:24 am Post subject: |
|
|
Since data needs to be reformatted; |
|
Back to top |
|
|
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Fri Aug 28, 2015 6:25 am Post subject: |
|
|
If there are too many rows to be inserted, you could "unload" your source table with a SELECT making all the needed reformats running under DSNTIAUL and, with a propper load statement, load the stuff into the target table
regards
Christian |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Aug 28, 2015 6:38 am Post subject: |
|
|
Do the reformatting in the SELECT eg (not real code but shows you the concept)
Code: |
SELECT cola, cola+somevalue as colz, colb FROM old table |
will select 2 columns (cola and colb) from the table and create a new column (colz) based on the value of cola. You can use the CASE statement to apply a varying value as for your EXP column. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Fri Aug 28, 2015 7:08 am Post subject: |
|
|
Ok thats good idea.thanks
Instead of reformatting while unloading, want to do it while loading.
So how to keep the condition in load statement. And do I need to change the data format from FILE S9(9) COMP to Integer of table field ? If yes, how to change? |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Fri Aug 28, 2015 9:11 am Post subject: |
|
|
Why are you insisting on doing an unload? You can insert into table b the row that you have just selected from table a along with the derived columns. All one statement. One oass of the data. Have you started trying things out with SPUFI? _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Fri Aug 28, 2015 9:33 am Post subject: |
|
|
Please post your columns of the new table to which you want the load of the data to happen. _________________ Shekar
Grow Technically |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Aug 28, 2015 10:08 am Post subject: Re: DB2 unload , reformat and load |
|
|
SRI123 wrote: | Question is what is the unload jcl and load jcl used so that data can be modified and loaded back ?
Thanks |
Sri123,
Are these your home work class exercises? If so please state them. Secondly what exactly did you try so far? Show us what you have tried and then may be we can suggest an improvement or guide you in the right direction. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|