IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

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 All times are GMT + 6 Hours
Forum Index -> DB2
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Can we Insert duplicates in Primary U... DB2 0
No new posts Group comparison/update between two f... DFSORT/ICETOOL 8
No new posts Need to read duplicate rows from tabl... DB2 3
No new posts COnvert a column with mix of hex ,cha... DB2 5
No new posts Hex Table COBOL Programming 2

Back to Top