Need logic to implement
Moderators: chulett, rschirm, roy
Need logic to implement
I need guidance on the following issue.
I have a scenario like this.
From an oracle table A I will 80 million records. I need to check several conditions.
For example :
select * from TableA where CODE NOT IN ('A','B','C'........'F')
select * from TableA where CODE IN ('Z','X','Y')
I want to implement in Xtrm, is there any list operator "IN" like in datastage or should i use or condition like
if CODE <> 'A' or CODE <> 'B' .......... or CODE <> 'F' Then 'Y' else 'N'
Please guide me
I have a scenario like this.
From an oracle table A I will 80 million records. I need to check several conditions.
For example :
select * from TableA where CODE NOT IN ('A','B','C'........'F')
select * from TableA where CODE IN ('Z','X','Y')
I want to implement in Xtrm, is there any list operator "IN" like in datastage or should i use or condition like
if CODE <> 'A' or CODE <> 'B' .......... or CODE <> 'F' Then 'Y' else 'N'
Please guide me
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
Re: Need logic to implement
A couple of things.
Secondly, what you were given was not a 'workaround' but the resolution to your question and works just fine without any additional caveats as long as you're not doing substring matches - which you're not. The Index() function will return the position where the code was found, meaning a zero or FALSE response will mean it was not in the list.
However, I've reopened the topic since you obviosuly don''t have it working yet. Once you do you can come back and mark it Resolved.
Those would need to be ANDs to work, OR would always evaluate to TRUE.sriec12 wrote:if CODE <> 'A' or CODE <> 'B' .......... or CODE <> 'F' Then 'Y' else 'N'
Secondly, what you were given was not a 'workaround' but the resolution to your question and works just fine without any additional caveats as long as you're not doing substring matches - which you're not. The Index() function will return the position where the code was found, meaning a zero or FALSE response will mean it was not in the list.
However, I've reopened the topic since you obviosuly don''t have it working yet. Once you do you can come back and mark it Resolved.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Thanks everyone for replying.
Well In my case I don't think Index works in my case.
Index will look for one substring Index (string, substring, instance)....I am trying to match upto 10 items.......If those 10 items matches I need to assign 'Y'. I am trying to find the function with matches a group of substrings
Well In my case I don't think Index works in my case.
Index will look for one substring Index (string, substring, instance)....I am trying to match upto 10 items.......If those 10 items matches I need to assign 'Y'. I am trying to find the function with matches a group of substrings
It will work just fine. Nothing in the examples you've posted shows you needing to match multiple items. For example:
Would equate to:
Code: Select all
if CODE NOT IN ('A','B','C','D','E','F') then 'Y' else 'N'
Code: Select all
If Index('ABCDEF',CODE,1) Then 'N' Else 'Y'
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
I don't know what "U", a member of this forum will tell about index.sriec12 wrote:what do u mean by index?
Text-message abbreviations have a place, but it's not in forums. For answers to be effective, the recipients need to be able to understand the question. Many of the posters on this forum do not have English as a first language. Decrypting SMS-style abbreviations only makes their task of comprehension more difficult. You would not create system documentation using these abbreviations, please accord members here the same courtesy.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
Thats good to know.
Only place I have seen where this breaks is when one value is a substring of another value such as CODE IN ("ABCD","BC") in this case "BC" will have two matches with index function. Which will break the logic if you need to distinguish between ABCD and BC, if both need to have the same fate then you are good with that too.
In those cases as well you can use some character as prefix and suffix
such as "|":CODE:"|" IN ("|ABCD|","|BC|").
or in DataStage syntax
Only place I have seen where this breaks is when one value is a substring of another value such as CODE IN ("ABCD","BC") in this case "BC" will have two matches with index function. Which will break the logic if you need to distinguish between ABCD and BC, if both need to have the same fate then you are good with that too.
In those cases as well you can use some character as prefix and suffix
such as "|":CODE:"|" IN ("|ABCD|","|BC|").
or in DataStage syntax
Code: Select all
If index("|ABCD|,|BC|","|":CODE:"|",1) then "N" else "Y"
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.
OK... that's still not a substring match and you're not quite right on your changes. The extra steps are necessary if you want to check for codes like "AT" or "MATCH" against a larger string, say like "MATCHES". Both of those would give false positive return codes as they are both found in the larger string. So there needs to be delimiters around all of the instances to search for and the value to search for as well. Technically, your way you would get a false positive hit on a CODE value of ",D" for example. Probably not one of your values, I know, but you still should be protecting yourself.
Notice how there are now commas on both sides of each value and added around the CODE value as well for the check. This way you'd be hard pressed to get a false positive now.
ps. priyadarshikunal showed you the same thing with pipes around the values. Just trying to reinforce what they posted since you missed that key point.
Code: Select all
if Index(',AB,BD,DE,......,EF,', ',':CODE:',',1) then 'N' else 'Y'
ps. priyadarshikunal showed you the same thing with pipes around the values. Just trying to reinforce what they posted since you missed that key point.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers