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

Add leading text in DB2


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

New User


Joined: 06 Apr 2007
Posts: 33
Location: USA

PostPosted: Fri Jun 26, 2009 1:25 am
Reply with quote

I need to add a leading text to an already existing value in a particular column in DB2.

Leading text to add = 'Hello World'
Exisiting text in the column = 'America'
Output Should be 'Hello World America'.

Exisiting text is variable and long enough to use replace function. Is ther any other function in SQL that would solve this.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 26, 2009 2:56 am
Reply with quote

update
set column = concat('hello world', substr(column,1,posstr(column,' '))
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Jun 26, 2009 4:01 pm
Reply with quote

this would be better:
set column = concat('hello world', substr(column,1,posstr(column,' ') - 1)
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts TEXT-TO-PDF Compuware & Other Tools 1
Search our Forums:

Back to Top