ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Removing carriage returns from a string in ESQL

Post new topic  Reply to topic
 Removing carriage returns from a string in ESQL « View previous topic :: View next topic » 
Author Message
ENVYMB
PostPosted: Thu Nov 28, 2013 3:42 am    Post subject: Removing carriage returns from a string in ESQL Reply with quote

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
View user's profile Send private message
Esa
PostPosted: Thu Nov 28, 2013 4:34 am    Post subject: Re: Removing carriage returns from a string in ESQL Reply with quote

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
View user's profile Send private message
dogorsy
PostPosted: Thu Nov 28, 2013 5:09 am    Post subject: Re: Removing carriage returns from a string in ESQL Reply with quote

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
View user's profile Send private message
Simbu
PostPosted: Thu Nov 28, 2013 8:36 am    Post subject: Reply with quote

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
View user's profile Send private message
ENVYMB
PostPosted: Thu Dec 19, 2013 11:22 pm    Post subject: Reply with quote

Newbie

Joined: 19 Nov 2013
Posts: 7

Thank You for your replies.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Removing carriage returns from a string in ESQL
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.