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 IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 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


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