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

Clean up DB2 string from unreadable characters


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

New User


Joined: 28 Oct 2005
Posts: 89

PostPosted: Tue Sep 29, 2009 7:41 am
Reply with quote

Another way to cleanup string from unreadable characters.

For example we have to remove from the string all characters with hexadecimal code less then X'40' (space).

We can do this in following way:

Code:
With
Source (source_str) as
(select 'Wel' || X'00070d33' || 'come ' || X'33343f' || 'to DB2 !'
from sysibm.sysdummy1
)
,
Clean_up(source_str, result_str, posn, maxposn) as
(select source_str, varchar('', length(source_str)), 0, length(source_str)
from  Source
Union All
select source_str,
result_str || case When substr(source_str, posn + 1, 1) < X'40' Then ''
                          Else substr(source_str, posn + 1, 1) End,
posn + 1,  maxposn
From Clean_up Where posn + 1 <= maxposn
)
select source_str as "Source string", result_str "Result String"
From Clean_up
Where posn = maxposn
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
Search our Forums:

Back to Top