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

Have a column with 50 CH but want to update only last 10 CH


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sureshbabu.jv

New User


Joined: 11 Apr 2006
Posts: 41
Location: Chennai

PostPosted: Thu Aug 06, 2009 5:23 pm
Reply with quote

Hi,

I have a 50 CHAR Column. Want to update only last 10 Char. Is it possible to do that? If please provide me a Update query for reference?

Thank you!
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 06, 2009 5:55 pm
Reply with quote

What do you want to update it with ?

try something like

UPDATE TABLE A SET COL = (SELECT SUBSTR(COL,1,40)|| '10 CHARS'
FROM TABLE WHERE COL = A.COL )

be careful if the column is an index ..you might encounter -803 ...
Back to top
View user's profile Send private message
sureshbabu.jv

New User


Joined: 11 Apr 2006
Posts: 41
Location: Chennai

PostPosted: Thu Aug 06, 2009 6:18 pm
Reply with quote

Hi Ashimer,

I want to update last 10 char with like EMAR080609 for all the rows of 50 char column.


Thanks,
Suresh
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 06, 2009 6:33 pm
Reply with quote

Code:

UPDATE TABLE A SET COL = (SELECT SUBSTR(COL,1,40)|| 'EMAR080609'
FROM TABLE WHERE COL = A.COL )
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 06, 2009 6:53 pm
Reply with quote

Code:
UPDATE TABLE SET COL = SUBSTR(COL,1,40) || 'EMAR080609'
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Aug 06, 2009 6:59 pm
Reply with quote

Right Craq ..I missed a simple one ...
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 How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts first column truncated in search result IBM Tools 13
No new posts Split a record with data in a differe... DFSORT/ICETOOL 8
Search our Forums:

Back to Top