IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Update a table column (varchar)


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top