if then else issue
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
if then else issue
i have small req i am doing a look up to a fileset to get col B on key col A , A
is a key field in driver tbl and lookup fileset, if the lookup fails then col B will be empty
then i need to see if col A = 'REQ' then col B shud be "Request" else "Deny".
my code :
If IsNull(col B) or trim(col B) = ' ' Then If col A = 'REQ' then col B= 'Request' else col B= 'Deny' else col B
which comes in transformer next to lookup stage , but in the out put iam getting nothing its empty.
Thanks in Advance
is a key field in driver tbl and lookup fileset, if the lookup fails then col B will be empty
then i need to see if col A = 'REQ' then col B shud be "Request" else "Deny".
my code :
If IsNull(col B) or trim(col B) = ' ' Then If col A = 'REQ' then col B= 'Request' else col B= 'Deny' else col B
which comes in transformer next to lookup stage , but in the out put iam getting nothing its empty.
Thanks in Advance
Last edited by samsuf2002 on Thu Jun 14, 2007 6:16 am, edited 1 time in total.
hi sam here
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
Try putting Parentheses in your code.
If IsNull(col B) or trim(col A) = ' ' Then (If col A = 'REQ' then col B= 'Request' else col B= 'Deny') else col B
I am not sure if this is the problem. But you can try it.
If IsNull(col B) or trim(col A) = ' ' Then (If col A = 'REQ' then col B= 'Request' else col B= 'Deny') else col B
I am not sure if this is the problem. But you can try it.
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
If IsNull(col B) or trim(col A) = ' ' Then If col A = 'REQ' then col B= 'Request' else col B= 'Deny' else col B
Say you have two links one is the lookup link 'lu' and the other is the input link ip.
Try this code in the derivation of ColB in the output
Say you have two links one is the lookup link 'lu' and the other is the input link ip.
Try this code in the derivation of ColB in the output
Code: Select all
if(IsNull(lu.ColB)) then ( if(trim(ip.ColA)='REQ') then 'Request' else 'Deny') else lu.ColB
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
sorry for the mistake.
In the code above just change the "lu" to "ip" and then try.
Try this ---
|
|
V
Minhajuddin wrote:If IsNull(col B) or trim(col A) = ' ' Then If col A = 'REQ' then col B= 'Request' else col B= 'Deny' else col B
Code: Select all
if(IsNull(ip.ColB)) then ( if(trim(ip.ColA)='REQ') then 'Request' else 'Deny') else lu.ColB
In the code above just change the "lu" to "ip" and then try.
Try this ---
|
|
V
Code: Select all
if(IsNull(ip.ColB)) then ( if(trim(ip.ColA)='REQ') then 'Request' else 'Deny') else lu.ColB
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
samsuf2002 wrote:Minaj --I used your code but still iam getting only spaces, i checked the output i am getting from lookup stage, it returns 50 spaces since col B is char(50). i tried to remove spaces and put it as varchar but i am not getting it.
What didn't you get?
Can you give us some more info about your requirement?
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Participant
- Posts: 467
- Joined: Tue Mar 20, 2007 6:36 am
- Location: Chennai
- Contact:
One last try
Here you go
Say you have a link called 'ip' to the transformer.
Use this code in the derivation of ColB.
This thing should work.
If it doesn't please put the exact code you are using in the transformer.
Here you go
Say you have a link called 'ip' to the transformer.
Use this code in the derivation of ColB.
Code: Select all
If(IsNull(Trim(ColB)=0)) then ip.ColB else If(Trim(ColA)='REQ') then 'Request' else 'Deny'
If it doesn't please put the exact code you are using in the transformer.
Minhajuddin
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Premium Member
- Posts: 397
- Joined: Wed Apr 12, 2006 2:28 pm
- Location: Tennesse
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: