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 

Generate Sql Statement to Update Table using SORT

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


Joined: 05 Jan 2006
Posts: 43
Topics: 14

PostPosted: Sun Jan 21, 2007 9:46 pm    Post subject: Generate Sql Statement to Update Table using SORT Reply with quote

Hi ,

We Need some help in writing update query.

We have a input file of 10,000 records with account number and update value. We need to generate the update query along with Commits in betweej out of this
Code:

UPDATE table_name
SET market_value = 1111.11
WHERE account_number = 1234456 ;


Here the market value and the account number feilds are to be replaced with the input file.

Can some one please help me in creating the sortparm to generate the above queries. I have looked in the threads but could not find the sort parm. Instead i could find fileaid.

Thanks
Manoj Voona
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Sun Jan 21, 2007 11:13 pm    Post subject: Reply with quote

manojvoona,

If you are looking for a sort solution you should have posted in the Sort utilties forum instead of DB2 forum. Any try this untested DFSORT solution. The following Job generates sql statements and also adds a commit statement after every 100 records. I assumed that the account number starts at pos 1 for 6 bytes and the market value starts at pos 8 for 7 bytes.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
123456 1111.11                                     
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD *                                     
 SORT FIELDS=COPY                                   
 INREC IFTHEN=(WHEN=INIT,                           
       BUILD=(01,80,C';',6X,SEQNUM,3,ZD)),         
       IFTHEN=(WHEN=(89,2,CH,EQ,C'00'),             
      OVERLAY=(81:C'COMMIT;'))                     
                                                   
 OUTFIL OUTREC=(C'UPDATE TABLE_NAME ',/,           
                C'   SET MARKET_VALUE   = ',08,07,/,
                C' WHERE ACCOUNT_NUMBER = ',01,06,/,
                81,7,80:X)                         
/*


Hope this helps...

Cheers

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


Joined: 05 Jan 2006
Posts: 43
Topics: 14

PostPosted: Mon Jan 22, 2007 12:55 pm    Post subject: Reply with quote

Thanks Kolusu !!! thanks a lot.
This is awesome.


-Manoj Voona
Back to top
View user's profile Send private message Send e-mail
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