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 » character string to list

Post new topic  Reply to topic
 character string to list « View previous topic :: View next topic » 
Author Message
Esa
PostPosted: Thu Mar 29, 2012 1:27 am    Post subject: character string to list Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Code:
DECLARE foo CHAR 'one;two,three';
DECLARE myList LIST CAST(foo AS LIST DELIMITER ';')


This type of cast is unfortunately not supported.

Which would be the best performing way to get a list from a string in ESQL (if wrapping a java method is not applicable), the traditional brute force approach with POSITIONs and SUBSTRINGs, or casting the string to BLOB and parsing it into a little message tree with MRM? Or something I have overlooked?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Mar 29, 2012 1:58 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Well, you could review again the functions available in ESQL and see if they've snuck one in. An overly quick glance on my part doesn't show one, but I'm sure I was hasty.

You could also misuse EVALUATE, maybe.
Back to top
View user's profile Send private message
Esa
PostPosted: Thu Mar 29, 2012 2:57 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

My example is a bit incorrect, because LIST is actually not a real datatype but more like an interface. So I correct it like this:

Code:
DECLARE foo CHAR 'one;two,three';
DECLARE ref.foolist.foo[] = CAST(foo AS LIST DELIMITER ';')


or

Code:
DECLARE foo CHAR 'one;two,three';
DECLARE ref.foolist.foo[] = EXPLODE(foo DELIMITER ';')



Neither of these, of course, exist in ESQL. But it would be nice if one of them did. Not very probable to get this through with an enhancement request because you can always write ten or twenty lines of code to explode a string into an iterable entity.
Back to top
View user's profile Send private message
Esa
PostPosted: Thu Mar 29, 2012 5:11 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

Well, I decided to take the brute force approach.

But i must say that I managed to develop a really nice and efective little 15-line iterator function that even takes care of empty strings between delimiters.

Feels like having invented a wheel! I feel like a king

This is why ESQL lacks a string tokenizer! It would just make the work more boring and productive
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Mar 29, 2012 5:24 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Esa wrote:


This is why ESQL lacks a string tokenizer! It would just make the work more boring and productive


IMHO very few 'young' coders understand was tokenizer parsing is all about.
I may even still have the code somewhere around for one I wrote in PDP-11 Macro around 1977/78.

_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Esa
PostPosted: Thu Mar 29, 2012 5:31 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

smdavies99 wrote:

IMHO very few 'young' coders understand was tokenizer parsing is all about.


Das glaube me too
It's because they have it in java schon fertig. Just plug and spielen!
Back to top
View user's profile Send private message
th61678
PostPosted: Thu Sep 12, 2013 5:41 pm    Post subject: Still have the 15 tokenizer around? Reply with quote

Newbie

Joined: 12 Sep 2013
Posts: 1

I've come across the same situation and could really make use of a tokenizer to turn a CHAR into a list. If you still have those 15 line iterator function I would love to take look...save me some time.

Thanks!
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 » character string to list
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.