|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Removing carriage returns from a string in ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
ENVYMB |
Posted: Thu Nov 28, 2013 3:42 am Post subject: Removing carriage returns from a string in ESQL |
|
|
Newbie
Joined: 19 Nov 2013 Posts: 7
|
Hi,
requirement is to remove carriage return from an incoming string in ESQL. And i have tried below method and worked out.
DECLARE v_carriage CHAR;
SETv_carriage =CAST(X'0D' AS CHAR CCSID InputRoot.MQMD.CodedCharSetId);
SET v_dest = REPLACE(v_source,v_carriage, '');
This results in an output as below
if v_source is " store active at
london"
v_dest would be "store active at london"
i.e carriage return is removed and a space is added.
just curious to know if there is a way to avoid this space. ??
Thanks,
ENVYMB |
|
Back to top |
|
 |
Esa |
Posted: Thu Nov 28, 2013 4:34 am Post subject: Re: Removing carriage returns from a string in ESQL |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Please, wrap code with code tags (by clicking Code button in the editor).
Code: |
SET v_dest = REPLACE(REPLACE(REPLACE(v_source,v_carriage_and_space, v_carriage), v_space_and_carriage, v_carriage), v_carriage, '');
|
or something like that will give you 'store active atlondon' if that's what you wanted. REPLACE doesn't add a space if you don't tell it to. So the space must have been there already, on either side of the carriage return. |
|
Back to top |
|
 |
dogorsy |
Posted: Thu Nov 28, 2013 5:09 am Post subject: Re: Removing carriage returns from a string in ESQL |
|
|
Knight
Joined: 13 Mar 2013 Posts: 553 Location: Home Office
|
ENVYMB wrote: |
Hi,
requirement is to remove carriage return from an incoming string in ESQL. And i have tried below method and worked out.
DECLARE v_carriage CHAR;
SETv_carriage =CAST(X'0D' AS CHAR CCSID InputRoot.MQMD.CodedCharSetId);
SET v_dest = REPLACE(v_source,v_carriage, '');
This results in an output as below
if v_source is " store active at
london"
v_dest would be "store active at london"
i.e carriage return is removed and a space is added.
just curious to know if there is a way to avoid this space. ??
Thanks,
ENVYMB |
use LTRIM or RTRIM ( see which one you need ). also, safer as that will not remove embedded characters that might be valid. |
|
Back to top |
|
 |
Simbu |
Posted: Thu Nov 28, 2013 8:36 am Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
Convert v_source into BLOB and post here. It will tell you whether there is X'0D' or X'0A' or X'00' in the string. |
|
Back to top |
|
 |
ENVYMB |
Posted: Thu Dec 19, 2013 11:22 pm Post subject: |
|
|
Newbie
Joined: 19 Nov 2013 Posts: 7
|
Thank You for your replies. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|