LIKE operator in IF ELSE Condition
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
The Index() suggestion is akin to '%DELL%' rather than 'DELL%'. Use a simple substring check on the front of the string for that:
Code: Select all
If Link.Field[1,4] = 'DELL' then 'DELL' else if Link.Field[1,5] = 'Cisco' then 'Cisco' else 'N/A'
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Thanks for comments. My task is NOT to check exact string but should work as Oracle like command - Like 'DELL%.
Tried to use Index send by Kunnal but not parsing.
Craig If Link.Field[1,4] condition is working but what if we have values 'DELL12' or 'Cisco32'
if index("DELL", LkFrom_CMDB_Table_Reject.VENDOR )=1 then "DELL" else (if index("Cisco", LkFrom_CMDB_Table_Reject.VENDOR)=1 then "Cisco" else 'N/A')
Sarathi
Tried to use Index send by Kunnal but not parsing.
Craig If Link.Field[1,4] condition is working but what if we have values 'DELL12' or 'Cisco32'
if index("DELL", LkFrom_CMDB_Table_Reject.VENDOR )=1 then "DELL" else (if index("Cisco", LkFrom_CMDB_Table_Reject.VENDOR)=1 then "Cisco" else 'N/A')
Sarathi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
For processing efficiency load the first four characters into a stage variable, for example svFirstFour. Map to upper case if your data contain mixed case.
Code: Select all
If svFirstFour = "DELL" Then "DELL" Else If svFirstFour = "CISC" Then "Cisco" Else "N/A"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
If the condition is index()=1 then it will work like 'DELL%' and index()<>0 is similar to '%DELL%'.chulett wrote:The Index() suggestion is akin to '%DELL%' rather than 'DELL%'.
![Wink :wink:](./images/smilies/icon_wink.gif)
also the index command should be
if index(InputString, "DELL",1)=1 then "DELL" else (if index(InputString,"Cisco", 1)=1 then "Cisco" else 'N/A')
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
True, but my point was that it does a substring match across the entire string so can find it anywhere and without you specifically checking where it found the string it can get you in trouble. To me it makes much more sense to just look at the first four (or five) characters if that's all you want to check, whether that's via substring or left. More efficient and more 'self documenting'. Yours can look like a simple true/false/zero/one test to the untrained or hurried eye.priyadarshikunal wrote:If the condition is index()=1 then it will work like 'DELL%' and index()<>0 is similar to '%DELL%'.chulett wrote:The Index() suggestion is akin to '%DELL%' rather than 'DELL%'.![]()
![Wink :wink:](./images/smilies/icon_wink.gif)
-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