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 » Doubt about the esql function.

Post new topic  Reply to topic
 Doubt about the esql function. « View previous topic :: View next topic » 
Author Message
fpg8
PostPosted: Mon Apr 09, 2012 6:23 am    Post subject: Doubt about the esql function. Reply with quote

Novice

Joined: 26 Mar 2012
Posts: 15

I want to replace a chain, for example: "1234AC56789" to "**********".

Probe with esql function:

replace ('123456789 ',' [A-Za-z0-9] * ',' * ')

It does not work.

Any help?

Thank you very much.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Apr 09, 2012 6:27 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Your search string expression is incorrect.

http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fak05241_.htm

ESQL search string expressions are finite, not variable. If you want to use a variable search string expression from ESQL, call the java.lang.String class from your ESQL.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Mon Apr 09, 2012 6:42 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

lancelotlinc wrote:
Your search string expression is incorrect.

http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fak05241_.htm

ESQL search string expressions are finite, not variable. If you want to use a variable search string expression from ESQL, call the java.lang.String class from your ESQL.


No.

Use TRANSLATE instead of REPLACE.
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ak05261_.htm
Back to top
View user's profile Send private message
fpg8
PostPosted: Mon Apr 09, 2012 6:49 am    Post subject: Reply with quote

Novice

Joined: 26 Mar 2012
Posts: 15

try this sentence but did not work:

SET numero_tarjeta_for = TRANSLATE (InputRoot.XMLNSC.ns: comprarContenidoTarjetaRequest.ns: numero_tarjeta, '[A-Za-z0-9] *', '*');
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Apr 09, 2012 6:53 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fpg8 wrote:
try this sentence but did not work:

SET numero_tarjeta_for = TRANSLATE (InputRoot.XMLNSC.ns: comprarContenidoTarjetaRequest.ns: numero_tarjeta, '[A-Za-z0-9] *', '*');


As my associate pointed out, ESQL strings expressions are finite.

This is something the InfoCenter points out as well.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Apr 09, 2012 6:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fpg8 wrote:
try this sentence but did not work:

SET numero_tarjeta_for = TRANSLATE (InputRoot.XMLNSC.ns: comprarContenidoTarjetaRequest.ns: numero_tarjeta, '[A-Za-z0-9] *', '*');


The expression '[A-Za-z0-9]*' is a regular expression.

Does the documentation on the TRANSLATE function say that it accepts a regular expression?

What did your statement produce?

The documentation says that
Quote:
each occurrence of any character that occurs in the search string being replaced by the corresponding character from the replace string


So if you have a search string of 'A' and a replace string of '*', then all A's will be turned into *'s. If you have a search string of 'AB" and a replace string of '*&', then all A's will be turned into *'s and all B's will be turned into &'s.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Apr 09, 2012 6:56 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

The OP is trying to do a variable string search, which is not supported by ESQL. One way to accomplish same is by calling the String class to perform the search and replacement. There may be other ways. Perhaps a code snippet could help here if you want to suggest another way?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Mon Apr 09, 2012 6:59 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

lancelotlinc wrote:
There may be other ways.




lancelotlinc wrote:
Perhaps a code snippet could help here if you want to suggest another way?


Suppling the correct replacement string to the function as my most worthy associate indicates is one. In which event the OP's code snippet should work a treat.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Esa
PostPosted: Mon Apr 09, 2012 7:17 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Maybe something like this would do:

Code:
SET numero_tarjeta_for = REPLICATE('*',LENGTH(FIELDVALUE(InputRoot.XMLNSC.ns: comprarContenidoTarjetaRequest.ns:numero_tarjeta)));


Unless you want underscores, dots and other special charecters left in place, of course.
Back to top
View user's profile Send private message
fpg8
PostPosted: Mon Apr 09, 2012 7:50 am    Post subject: Reply with quote

Novice

Joined: 26 Mar 2012
Posts: 15

Esa wrote:
Maybe something like this would do:

Code:
SET numero_tarjeta_for = REPLICATE('*',LENGTH(FIELDVALUE(InputRoot.XMLNSC.ns: comprarContenidoTarjetaRequest.ns:numero_tarjeta)));


Unless you want underscores, dots and other special charecters left in place, of course.


Thank you very much for the reply. I will try.

For now, I did work like this:

SET numero_tarjeta_for = InputRoot.XMLNSC.ns:comprarContenidoTarjetaRequest.ns:numero_tarjeta;
SET numero_tarjeta = '';
SET i = 1;

IF (numero_tarjeta_for IS NOT NULL) THEN
X : WHILE i <= Length(numero_tarjeta_for) DO
SET numero_tarjeta = numero_tarjeta || '*';
SET i = i + 1;
END WHILE X;
END IF;
Back to top
View user's profile Send private message
fpg8
PostPosted: Mon Apr 09, 2012 8:03 am    Post subject: Reply with quote

Novice

Joined: 26 Mar 2012
Posts: 15

Esa,


It worked, Thank you for provide me ANSWERS.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Apr 09, 2012 9:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fpg8 wrote:
For now, I did work like this:

SET numero_tarjeta_for = InputRoot.XMLNSC.ns:comprarContenidoTarjetaRequest.ns:numero_tarjeta;
SET numero_tarjeta = '';
SET i = 1;

IF (numero_tarjeta_for IS NOT NULL) THEN
X : WHILE i <= Length(numero_tarjeta_for) DO
SET numero_tarjeta = numero_tarjeta || '*';
SET i = i + 1;
END WHILE X;
END IF;


Whatever works for you.

TRANSLATE would also do this. So would REPLACE as you had it with the correct string. So would something like:

Code:
SET numero_tarjeta  = REPLICATE('*',LENGTH(COALESCE(InputRoot.XMLNSC.ns:comprarContenidoTarjetaRequest.ns:numero_tarjeta,''))


Many possible answers.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Apr 09, 2012 8:11 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Seemed very complicate when something simple would have made it too like
Code:
SET maskedpart = replicate('*',12);
SET lastdigits = right(cardnumber,4);
SET fieldvalue = maskedpart || lastdigits;


Well, there's a million ways to ....

Note that no animals whatsoever were harmed in this post
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Mon Apr 09, 2012 10:20 pm    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

fjb_saper wrote:
Well, there's a million ways to ....

@OP: First challenge: Find something (that works)... then (second challenge): Make it (probably find something else ) work best for you (often performance is a requirement).

fjb_saper wrote:
Note that no animals whatsoever were harmed in this post

With some experience you will then just do things in a certain way. Poor cat btw.
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Apr 10, 2012 4:40 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

fjb_saper wrote:
Well, there's a million ways to ....


There are.

fjb_saper wrote:
Note that no animals whatsoever were harmed in this post


Speak for yourself.....
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » Doubt about the esql function.
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.