Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Update a table column (varchar)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
TS70363

New User


Joined: 07 Apr 2010
Posts: 94
Location: Bangalore, India

PostPosted: Mon Sep 02, 2013 6:13 pm    Post subject: Update a table column (varchar)
Reply with quote

Hi,

Table :
C1: Varchar(60)
C2: Char(02)

Current data in the table

Code:

423<                                                         10
424<                                                         10
425<                                                         10
00000426<                                                    10
427<                                                         10
00000429<                                                    10


The requirement is to update the table column C1.
1. Select row and pad leading zeroes to make it 8 bytes wherever data in column C1 is less than 8 bytes (in example - 423)
2. Update all the rows in the table


Any help is much appreciated.

Thanks
TS70363
Back to top
View user's profile Send private message

MOHAN KUMAR DURAIRAJAN

New User


Joined: 16 Apr 2012
Posts: 11
Location: INDIA

PostPosted: Tue Sep 03, 2013 5:50 pm    Post subject:
Reply with quote

Hey TS70363 ,

This requirement is very simple. Need to find the length and need to do left padding.

Find the querry below. It will be helpful.


UPDATE TABLE NAME
SET COLUMN NAME = LPAD(COLUMN NAME,8,'0')
WHERE LENGHT(COLUMN NAME) < 8

Thanks,
Mohan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us