SPUFI Update Table Columns
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Database

#1: SPUFI Update Table Columns Author: NorthernDancerLocation: DOWNTOWN BUFFALO, NY PostPosted: Fri Feb 26, 2016 11:17 am
    —
I want to use SPUFI if possible to plug some columns with test data. And I want to Concatenate like parts of 2 existing columns together. So the new data becomes easily recognized. Say for example 1st 5 bytes of ZIPCODE concatenated with 1st 10 bytes of CityName. Would I just use the Concatenate character (whatever that is) between them on the SET ?? So then maybe SET HUBID = ZIPCODE(1:5)|CityName(1:10) ??

#2:  Author: kolusuLocation: San Jose PostPosted: Fri Feb 26, 2016 12:11 pm
    —
NorthernDancer,

You can do it quite easily as long as the target and source columns have the same attributes. If you have different attributes then you need to convert the source column to match target column attributes.

Check this link for examples

http://www.mvsforums.com/helpboards/viewtopic.php?p=58823#58823

#3:  Author: NorthernDancerLocation: DOWNTOWN BUFFALO, NY PostPosted: Mon Feb 29, 2016 3:49 pm
    —
Thank You Sir, this is it easily as you said..............
Code:

UPDATE DB2T.OUR_CUST                                   
SET HUB_CUST_ID =                                     
CHAR('HUB-'||SUBSTR(ZIP_OR_POSTAL_CDE,1,5)||CHAR('-')||
SUBSTR(CIN_CUST_ID,1,9))                               
WHERE                                                 
ENTY_ID = 'YYYY' AND                                   
AREA_ID = 'ZZZZ' AND                                   
CIN_CUST_ID > '  ' AND                                 
CIN_CUST_ID < '000061836' AND                         
ZIP_OR_POSTAL_CDE > '  ' AND                           
ADR_LINE_3 > '  ' AND                                   
HUB_CUST_ID = '  ' AND                                 
EXPR_DTE = '9999-12-31'                               
;

#4:  Author: kolusuLocation: San Jose PostPosted: Mon Feb 29, 2016 6:48 pm
    —
NorthernDancer,

Glad you got it working but I would suggest you code the sql's so that easy to read and understand. Something like this
Code:

----+----1----+----2----+----3----+----4----+----5----+----6
UPDATE DB2T.OUR_CUST                                       
   SET HUB_CUST_ID       = CHAR(('HUB-')                 ||
                           SUBSTR(ZIP_OR_POSTAL_CDE,1,5) ||
                           CHAR('-')                     ||
                           SUBSTR(CIN_CUST_ID,1,9))         
 WHERE ENTY_ID           = 'YYYY'                           
   AND AREA_ID           = 'ZZZZ'                           
   AND CIN_CUST_ID       > '  '                             
   AND CIN_CUST_ID       < '000061836'                     
   AND ZIP_OR_POSTAL_CDE > '  '                             
   AND ADR_LINE_3        > '  '                             
   AND HUB_CUST_ID       = '  '                             
   AND EXPR_DTE          = '9999-12-31'                     
   ;                                                       

#5:  Author: NorthernDancerLocation: DOWNTOWN BUFFALO, NY PostPosted: Tue Mar 01, 2016 4:31 pm
    —
Yeh, I just slapped it together to test it and zap some test rows. I like your way a lot better and neater. I didn't actually know you could leave so many blanks on separate cards and it still parses together OK. Idea



MVSFORUMS.com -> Database


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group