If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Removing New line character from a field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-10, 10:49
mac4rfree mac4rfree is offline
Registered User
 
Join Date: Jul 2009
Posts: 52
Removing New line character from a field

Hi Guys,

Somehow one of my column is having a new line character as its data. I want to show it in the single line. This is causing me an issue.

Can you please let me know how to remove the New line character.

I am pasting my output of my query which i ran it from the server.

Code:
crd02:/clocal/fastcar/user/fcfmetl $ ARGET_HISTORY_VW TVW where I_TRGT_HIST_SAN = 21443 with ur"                   <

X_TRGT_COMNT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    75 PERCENT OF STATUS
REALIGN .0359 FROM PHB20
Thanks for your help in advance.

Regards,
Magesh
Reply With Quote
  #2 (permalink)  
Old 06-07-10, 10:53
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
You can use:

Replace (your_string, X'0d', '')

Lenny
Reply With Quote
  #3 (permalink)  
Old 06-07-10, 10:56
mac4rfree mac4rfree is offline
Registered User
 
Join Date: Jul 2009
Posts: 52
Still having the issue Lenny...

Quote:
db2 "select replace(X_TRGT_COMNT,X'0d','') from FCFM.TARGET_HISTORY_VW TVW where I_TRGT_HIST_SAN = 21443 with ur"

1

----------------------------------------------------------------------------------------------------------
75 PERCENT OF STATUS
REALIGN .0359 FROM PHB20


1 record(s) selected.
Reply With Quote
  #4 (permalink)  
Old 06-07-10, 10:58
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
replace(replace(source_string,chr(13),''),chr(10), '')

Andy
Reply With Quote
  #5 (permalink)  
Old 06-07-10, 11:05
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Arrow

Quote:
Originally Posted by mac4rfree View Post
Still having the issue Lenny...
Where '' is 2 quotes, not a double quote....

Lenny
Reply With Quote
  #6 (permalink)  
Old 06-07-10, 11:10
mac4rfree mac4rfree is offline
Registered User
 
Join Date: Jul 2009
Posts: 52
Andy ,, that did the trick

@Lenny,, I think the hex value for new line is X'0A'.. I tried the below query still not able to get the result which i wanted but andy solution was on target....

Quote:
db2 "select replace(X_TRGT_COMNT,X'0A','') from FCFM.TARGET_HISTORY_VW TVW where I_TRGT_HIST_SAN = 21443 with ur"

1
---------------------------------------------------------------------------------------------------------------
REALIGN .0359 FROM PHB20 1 record(s) selected.
Quote:
db2 "select replace(replace(X_TRGT_COMNT,chr(13),''),chr(10), '') from CFM.TARGET_HISTORY_VW TVW where I_TRGT_HIST_SAN = 21443 with ur"

1
-----------------------------------------------------------------------------------------------------------------
75 PERCENT OF STATUSREALIGN .0359 FROM PHB20
1 record(s) selected.
Reply With Quote
  #7 (permalink)  
Old 06-07-10, 12:33
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Quote:
Originally Posted by mac4rfree View Post
Andy ,, that did the trick

@Lenny,, I think the hex value for new line is X'0A'.. I tried the below query still not able to get the result which i wanted but andy solution was on target....
Maybe. For mainframe is X'0D', for other systems could be different.
Lenny
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On