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 » [Solved] ESQL SUBSTRING BEFORE

Post new topic  Reply to topic
 [Solved] ESQL SUBSTRING BEFORE « View previous topic :: View next topic » 
Author Message
DTechBuddy
PostPosted: Wed May 13, 2009 5:45 am    Post subject: [Solved] ESQL SUBSTRING BEFORE Reply with quote

Novice

Joined: 05 May 2009
Posts: 20

Hi Guyz,

I have a requirement to select only the value occuring before the character '#'.
E.g. if String is "HelloABC#Company", then i want to retrieve the value "HelloABC".

I am working on WMBT 6.0.2.

Thnx in advance.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 13, 2009 5:53 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Grand High Poobah

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

DTechBuddy wrote:
I have a requirement to select only the value occuring before the character '#'.
E.g. if String is "HelloABC#Company", then i want to retrieve the value "HelloABC".


Thank you for sharing.

Given the subject line of this post, I wonder what the question is you're implying....?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
DTechBuddy
PostPosted: Wed May 13, 2009 6:02 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Novice

Joined: 05 May 2009
Posts: 20

[quote]I wonder what the question is you're implying....? [/quote]


As the eg. stated before, I have to retrieve the value "HelloABC" from "HelloABC#Company".
The position of '#' can be anything (Not fixed).
How to do this?
The syntax :- SUBSTRING (MyValue FROM <INTEGER>).
I don't have this Integer value.

I recall reading somewhere, that WMBT 6.0.1.3 ESQl has SUBSTRING BEFORE and AFTER facilities.
Is there anything of this sort in WMBT6.0.2 ESQl?
Back to top
View user's profile Send private message
dmw1986
PostPosted: Wed May 13, 2009 6:05 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Apprentice

Joined: 24 Sep 2008
Posts: 35

Vitor wrote:
DTechBuddy wrote:
I have a requirement to select only the value occuring before the character '#'.
E.g. if String is "HelloABC#Company", then i want to retrieve the value "HelloABC".


Thank you for sharing.

Given the subject line of this post, I wonder what the question is you're implying....?


I think he wants to do a substring of any text that falls before #. So if the string is..

'TextBeforePound#BlahBah' he wants 'TextBeforePound'

or

'CompanyABC-CompnyBCA#GoGreen' he wants 'CompanyABC-CompnyBCA'

So the substring length will vary depending on where the # is in the string.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 13, 2009 6:08 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Grand High Poobah

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

DTechBuddy wrote:
I recall reading somewhere, that WMBT 6.0.1.3 ESQl has SUBSTRING BEFORE and AFTER facilities.
Is there anything of this sort in WMBT6.0.2 ESQl?


Oh, right, I see! Sorry about that; the coffee machine is broken and my brain's having to make do with water....

DTechBuddy wrote:
I don't have this Integer value.


No, but you could easily obtain it by finding the position of the '#'. 2 lines of ESQL not 1 but should work like a charm.

And an improvement waiting for you once you upgrade.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 13, 2009 6:10 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Grand High Poobah

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

dmw1986 wrote:
I think he wants to do a substring of any text that falls before #.


I think you're right. And I think I failed to notice he (or she) is on a previous version not containing the function in question.

Even I have off days. And I claim external circumstances; the SLA on coffee machine fixing here is ridiculously long!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 13, 2009 6:11 am    Post subject: Re: ESQL SUBSTRING BEFORE Reply with quote

Grand High Poobah

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

Vitor wrote:
2 lines of ESQL not 1 but should work like a charm.


Or 1 slightly chunky line.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Wed May 13, 2009 6:23 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi All,

I'm a bit annoyed by this topic, so many posts and no one has even come to the point of answering it....and it's not that the question was not understandable in the first post itself...what did I miss ?

@DTechBuddy:

Code:
SET someVar = SUBSTRING('HelloABC#Company' FROM 1 FOR (POSITION('#' IN 'HelloABC#Company')-1));


Regards.
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed May 13, 2009 7:41 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

elvis_gn wrote:
I'm a bit annoyed by this topic, so many posts and no one has even come to the point of answering it....and it's not that the question was not understandable in the first post itself...what did I miss ?


I think a lot of people were wondering why the OP didn't just use
Code:
SUBSTRING('HelloABC#Company' BEFORE '#');
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed May 13, 2009 10:02 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:
I think a lot of people were wondering why the OP didn't just use
Code:
SUBSTRING('HelloABC#Company' BEFORE '#');


Because that's not in v6.0, only in v6.1?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed May 13, 2009 10:40 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

well, technically DTechBuddy only specified the level of *Toolkit* that was being used...
Back to top
View user's profile Send private message
DTechBuddy
PostPosted: Wed May 13, 2009 9:55 pm    Post subject: Re : Solved. Thnx. Reply with quote

Novice

Joined: 05 May 2009
Posts: 20

Hey Guyz,

Thnx to all.
Thnx Elvis. Vitor's hint to find the position of '#' solved my query which matched ur code solution.

Cheers.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu May 14, 2009 12:14 am    Post subject: Re: Re : Solved. Thnx. Reply with quote

Grand High Poobah

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

DTechBuddy wrote:
Vitor's hint to find the position of '#' solved my query which matched ur code solution.


Enjoy your fishing, and well done you!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mgk
PostPosted: Thu May 14, 2009 1:01 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Don't forget to cope with the possibility of the '#' not occuring in the input data. I believe that the above code will cause an exception in this case as your POSITION will return a 0, which will then become -1 and so the StringLength parameter will be "less than the StartPosition" which is not allowed if you read the docs for SUBSTRING.

Kind Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
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 » [Solved] ESQL SUBSTRING BEFORE
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.