Author |
Message
|
anshu |
Posted: Wed Jun 07, 2006 12:46 pm Post subject: NESTED IF |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
Is there a logic error with this statement
IF Condition THEN -- first if
statements
IF CONDITION2 THEN
statements
ELSE
statements
END IF;
ELSE -- else for the first if
statements
END IF; |
|
Back to top |
|
 |
madi |
Posted: Wed Jun 07, 2006 12:56 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
i dont think eSQL allows an ELSE after the first END IF but i might be wrong
i know i had this problem when i was coding ..... i would have go back to my code and see how i did it
it will be easier if u post the code u are using rather than posting something like this
--madi |
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 1:07 pm Post subject: madi, here it is |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
madi - the problem is the 2nd IF is not getting executed (even though position2 is > 1 and < 36), instead the statements inside the else corresponding to the 2nd IF is getting executed. please help...thanks
SET POSITION1 = POSITION('$' IN InputRoot.MRM.ADD);
IF POSITION1 > 1 AND POSITION1 < 36 THEN
SET OutputRoot.MRM.MESSAGE.FIELD[1] = SUBSTRING(InputRoot.MRM.ADD FROM 1 FOR (POSITION1 - 1));
SET POSITION1 = POSITION1 + 1;
SET TEMPSTRING = SUBSTRING(InputRoot.MRM.ADD FROM POSITION1);
SET POSITION2 = POSITION('$' IN TEMPSTRING);
IF POSITION2 > 1 AND POSITION2 < 36 THEN
SET OutputRoot.MRM.MESSAGE.FIELD[2] = SUBSTRING(TEMPSTRING FROM POSITION1 FOR (POSITION2 - 1));
SET POSITION2 = POSITION2 + 1;
SET OutputRoot.MRM.MESSAGE.FIELD[3] = SUBSTRING(TEMPSTRING FROM POSITION2 FOR 35);
SET OutputRoot.MRM.MESSAGE.FIELD[3] = RTRIM(OutputRoot.MRM.MESSAGE.FIELD[3]);
ELSE
SET OutputRoot.MRM.MESSAGE.FIELD[2] = SUBSTRING(TEMPSTRING FROM 1 FOR 35);
SET OutputRoot.MRM.MESSAGE.FIELD[2] = RTRIM(OutputRoot.MRM.MESSAGE.FIELD[2]);
END IF;
ELSE
SET OutputRoot.MRM.MESSAGE.FIELD[1] = SUBSTRING(InputRoot.MRM.ADD FROM 1 FOR 35);
SET OutputRoot.MRM.MESSAGE.FIELD[1] = RTRIM(OutputRoot.MRM.MESSAGE.FIELD[1]);
END IF; |
|
Back to top |
|
 |
madi |
Posted: Wed Jun 07, 2006 1:15 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
Code: |
IF POSITION2 > 1 AND POSITION2 < 36 THEN |
are u sure this condition being met??
make sure it is being met
so as i understand it you are not getting any errors while u deploy it but it just does not work the way u want it to right??
is this is the case, im pretty sure the condition is not being met
debug ur eSQL and monitor POSITION2 as it is created and changed
--madi |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 07, 2006 1:16 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Are you positive that the POSITION2 variable does hold a value between 1 and 36? Or just positive that it *should* hold a value in range?
Does the debugger show the correct value? What happens when you step through the ESQL code? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
madi |
Posted: Wed Jun 07, 2006 1:17 pm Post subject: |
|
|
 Chevalier
Joined: 17 Jan 2006 Posts: 475
|
perfect timing jeff  |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 07, 2006 1:19 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I didn't preview before submitting...
 _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 3:24 pm Post subject: This is my input |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
P.O.BOX 10$DRIVE$USA is my InputRoot.MRM.ADD
I would think that POSITION 1 = 10, the first occurence of $
POSITION 2 = 6 the 2nd occurence of $.
I am a WBIMB newbie, so haven't used the debugger. Sorry. So I am thinking that POSITION2 would be 6. I have not seen it in debug.
- Anshu |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 07, 2006 3:43 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What madi and I are saying is - learn the debugger and see it there.
Or you can use Environment, and use a trace node afterwards. This would be to add a bunch of SET statements that assigned various fields in Environment.Variables to the value of POSITION1 and POSITION2 and TEMPSTRING and etc. Then in your trace node add a pattern like ${Environment} or ${Environment.Variables}, and you will see the values. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 4:35 pm Post subject: Thanks Jeff |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
I used a trace node after the compute node. However I just used {Root} {ExceptionList}. I'll add ${Environment} to it and let you know.
But do you see any problem with the syntax as such for what I am doing, which is to break the P.O.BOX 10$DRIVE$USA into 3 lines of data
P.O.BOX 10,
DRIVE,
USA
I checked the esql manual and can't find a similar syntax there. |
|
Back to top |
|
 |
JT |
Posted: Wed Jun 07, 2006 4:37 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
........or you can activate a debug-level trace of the message flow to discover the values that are being assigned to POSITION1 & POSITION2.
No codng changes required. |
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 4:46 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 5:09 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
Sorry to sound stupid..
But how do I use Environment in the compute node so as to trace it with {Environment} in the trace node.
Please let me know what change I should do in the compute node for this. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Jun 07, 2006 5:17 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Code: |
SET POSITION1 = POSITION('$' IN InputRoot.MRM.ADD);
SET Environment.Variables.POSITION1 = POSITION1;
IF POSITION1 > 1 AND POSITION1 < 36 THEN
SET OutputRoot.MRM.MESSAGE.FIELD[1] = SUBSTRING(InputRoot.MRM.ADD FROM 1 FOR (POSITION1 - 1));
SET POSITION1 = POSITION1 + 1;
SET TEMPSTRING = SUBSTRING(InputRoot.MRM.ADD FROM POSITION1);
SET Environment.Variables.TEMPSTRING = TEMPSTRING
SET POSITION2 = POSITION('$' IN TEMPSTRING);
SET Environment.Variables.POSITION2 = POSITION2; |
Etc.
You're probably better off using user trace, as JT suggests. Or at least, learning how to do so long term. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
anshu |
Posted: Wed Jun 07, 2006 6:39 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2006 Posts: 19
|
I think I may have a problem in the earlier code. The code should be
SET OutputRoot.MRM.FIELD[2] = SUBSTRING(TEMPSTRING FROM 1 FOR (POSITION2 - 1));
This is only my guess. I'll employ the trace tomorrow and let you guys know how it goes.
-Anshu |
|
Back to top |
|
 |
|