Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 93
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us