|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
What is a good method to look for varying length values in a |
« View previous topic :: View next topic » |
Author |
Message
|
jrsetters |
Posted: Thu Aug 30, 2012 8:48 am Post subject: What is a good method to look for varying length values in a |
|
|
 Acolyte
Joined: 24 Aug 2011 Posts: 72 Location: Cincinnati, OH
|
I have a long list of department prefixes that range from 2 to 6 characters in length that I want to filter out of a downstream system. I can't really use IN, I guess because I don't have the whole value to look for and can't substring out specific character lengths.
I don't know if it is possible to check multiple values from a CONTAINS or LIKE Operator. I'd prefer not to write out 70 individual statements.
How would you guys do it? It's about 70 different variations of 'department starts with' I need to account for (ie any department that begins with 'UN', or 'GHW' or 'GHRAD' etc). |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 30, 2012 8:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Can you sort the 70 into subsets, all at the same length?
I.e check if SUBSTRING(2) IN ('UH','AB','MN','LQ',) and then do an OR over each subset? |
|
Back to top |
|
 |
jrsetters |
Posted: Thu Aug 30, 2012 8:58 am Post subject: |
|
|
 Acolyte
Joined: 24 Aug 2011 Posts: 72 Location: Cincinnati, OH
|
I don't think so because most of these are hospital nursing units and we don't necessarily want to filter out everything that is similar. For instance if we had the Radiology Unit at University Hospital, we might want to filter out:
UHRADX
UHRADUS
UHRADEKG
but keep
UHRADMRI
UHRADO
UHRADPULM
or something along those lines. They are fairly specific about their list, but there is little in common that would let me use a category like that.
EDIT: I see more what you are saying now, sometimes I am slow on the uptake. So just DECLARE the variable once then do a series of OR SUBSTRINGS of 2,3,4,5, and 6 and sort them into there. That I definitely do, I just didn't know if there was a lazy way to put them all in one bracket with an OR or comma between each one. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 30, 2012 9:17 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you work from longest to shortest subsets, that will help somewhat.
But the situation may not allow you to do what you want.
Presume you have to throw out anything that starts with UH, but keep things that start with UHABC unless it starts with UHABCA.
You have to have three checks to solve that. There's no way to solve it otherwise, even with a regex. If it doesn't match UHABCA, then it might still match UHABC or UH. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Aug 30, 2012 12:28 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
|
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
|
|
|
|