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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Have a column with 50 CH but want to update only last 10 CH
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    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 -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
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm


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