Author |
Message
|
xstuvw |
Posted: Tue Nov 29, 2011 1:05 pm Post subject: |
|
|
Novice
Joined: 29 Nov 2011 Posts: 21
|
I intended for the code to generate an attribute under the child of XMLNSC called msgid. Instead, the msgid is placed under the XMLNSC tag when I use the reference outRoot.
Also, when I use MOVE outRoot FIRSTCHILD, it does not seem to reference the child of XMLNSC. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 29, 2011 1:12 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
xstuvw wrote: |
I intended for the code to generate an attribute under the child of XMLNSC called msgid. |
I don't see how the code you posted was ever going to achieve that, as it doesn't seem to refer to anything called msgid or any XML attribute (the creation of which would require fairly specific code or you'd get an element not an attribute).
Also MsgId (rather than msgid) is a child of MQMD not XMLNSC.
xstuvw wrote: |
Also, when I use MOVE outRoot FIRSTCHILD, it does not seem to reference the child of XMLNSC. |
Ok, I don't see a MOVE...FIRSTCHILD in your posted code either. I'm clearly missing something significant.... _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
xstuvw |
Posted: Tue Nov 29, 2011 1:15 pm Post subject: |
|
|
Novice
Joined: 29 Nov 2011 Posts: 21
|
Sorry, I wasn't too clear before.
I use:
SET outRoot.(XMLNSC.Attribute)msgid = InputRoot.MQMD.CorrelId;
but only later on in my ESQL (not posted above). If outRoot pointed to the child of XMLNSC, then msgid would fall under it instead of XMLNSC. But it doesn't (in the debugger, or in the returned message).
I only brought up the MOVE ... FIRSTCHILD as something else I've tried that doesn't garner expected results either. I replaced MOVE ... TO ... with MOVE ... FIRSTCHILD. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 29, 2011 1:16 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I agree with Vitor. Thanks for posting the user trace, which is exactly the right way to debug this type of problem. But please be clear and consistent about what you are trying to accomplish. So far you have posted ESQL snippet A, then posted some user trace executing ESQL snippet B, then discussed the problem in terms of ESQL snippet C which is different from both A and B.
You really can't blame us for getting confused  |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 29, 2011 1:29 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kimbert wrote: |
You really can't blame us for getting confused  |
As I've said many times, I'm psychotic not psychic.
Please post:
- the ESQL (all the ESQL) with which you're attempting this task
- the user trace of that ESQL being executed
- a clear explaination of what you expect to be happening
Better information, better advice. Remember we can't see what you're doing & don't know what you have or have not tried already that you've not mentioned. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
xstuvw |
Posted: Tue Nov 29, 2011 1:33 pm Post subject: |
|
|
Novice
Joined: 29 Nov 2011 Posts: 21
|
aaaaaaaaa
Last edited by xstuvw on Wed Nov 30, 2011 1:07 pm; edited 1 time in total |
|
Back to top |
|
 |
McueMart |
Posted: Tue Nov 29, 2011 2:47 pm Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
The UserTrace seems to match with your code and is working as intended...
The LASTMOVE(outRoot) is evaluating to TRUE, which means you enter the IF and RETURN TRUE (exit the function). The code to set the attribute is not evaluated.
So if you change your code to:
Code: |
DECLARE serviceTopic CHARACTER 'UpdateCall';
CREATE LASTCHILD OF OutputRoot.XMLNSC NAME serviceTopic;
-- Determine the root tag of the XML to be generated.
DECLARE outRoot REFERENCE TO OutputRoot.XMLNSC;
MOVE outRoot TO OutputRoot.XMLNSC.UpdateCall; -- FIRSTCHILD;
--CASE
--WHEN serviceTopic = 'CreateCall' THEN MOVE outRoot TO OutputRoot.XMLNSC.CreateCall;
--WHEN serviceTopic = 'AddCallComments' THEN MOVE outRoot TO OutputRoot.XMLNSC.AddCallComments;
--WHEN serviceTopic = 'UpdateCall' THEN MOVE outRoot TO OutputRoot.XMLNSC.UpdateCall;
--WHEN serviceTopic = 'CancelCall' THEN MOVE outRoot TO OutputRoot.XMLNSC.CancelCall;
--END CASE;
IF LASTMOVE(outRoot) THEN
-- Generate the attributes.
SET outRoot.(XMLNSC.Attribute)msgid = InputRoot.MQMD.CorrelId;
RETURN TRUE;
END IF;
|
Does that work? I might be missing something...this thread is a bit confusing! |
|
Back to top |
|
 |
xstuvw |
Posted: Tue Nov 29, 2011 3:06 pm Post subject: |
|
|
Novice
Joined: 29 Nov 2011 Posts: 21
|
I'm sorry for this being so confusing, if possible please only consider from this post an onward. I've narrowed down my problem. I will state my ESQL in two boxes, Box 1 works successfully while Box 2 is my current problem.
BOX 1 - Success - outRoot references the correct field.
Code: |
SET OutputRoot.XMLNSC.UpdateCall = '';
DECLARE outRoot REFERENCE TO OutputRoot.XMLNSC.UpdateCall
|
BOX 2 - Failure - outRoot references nothing.
Code: |
DECLARE serviceTopic CHARACTER 'UpdateCall';
CREATE LASTCHILD OF OutputRoot.XMLNSC NAME serviceTopic;
DECLARE outRoot REFERENCE TO OutputRoot.XMLNSC.UpdateCall
|
As you can see, the only difference is in the first two lines of the code between the boxes. However, because Box 2 is "dynamically" creating a child using a CHARACTER variable I receive problems when I go to reference it. I hope this is clear... I am really struggling with this issue. |
|
Back to top |
|
 |
McueMart |
Posted: Tue Nov 29, 2011 3:23 pm Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
The problem is now clear but im not sure if I can help (dont have my Toolkit in front of me!). I would say the only difference between your two snippets of ESQL is that the first assigns an empty CHAR to the value, whereas the second doesnt.
Code: |
DECLARE serviceTopic CHARACTER 'UpdateCall';
CREATE LASTCHILD OF OutputRoot.XMLNSC NAME serviceTopic VALUE '';
DECLARE outRoot REFERENCE TO OutputRoot.XMLNSC.UpdateCall
|
Does the problem still occur with this? |
|
Back to top |
|
 |
rekarm01 |
Posted: Tue Nov 29, 2011 3:34 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
xstuvw wrote: |
However, because Box 2 is "dynamically" creating a child using a CHARACTER variable I receive problems when I go to reference it. I hope this is clear... I am really struggling with this issue. |
What does the usertrace look like for Box 2? |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 29, 2011 3:43 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
BOX 2 - Failure - outRoot references nothing. |
How do you know that? By looking at a user trace? By looking in the debugger? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Nov 29, 2011 9:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
It might be a problem of scope.
Within the same scope you are only supposed to declare a value / reference once.
What happens if for you second declare (second box) you use MOVE instead?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Luke |
Posted: Wed Nov 30, 2011 2:04 am Post subject: |
|
|
Centurion
Joined: 10 Nov 2008 Posts: 128 Location: UK
|
fjb_saper wrote: |
It might be a problem of scope.
Within the same scope you are only supposed to declare a value / reference once.
What happens if for you second declare (second box) you use MOVE instead?  |
Or (assuming the reference has already been declared) you could use the AS clause of the CREATE statement. This MOVEs the reference at the same time as creating the new field. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Nov 30, 2011 2:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
kimbert wrote: |
Quote: |
BOX 2 - Failure - outRoot references nothing. |
How do you know that? By looking at a user trace? By looking in the debugger? |
This was my original point. The debugger may not provide any useful information about REFERENCE variables that correctly point to existing locations that do not yet have values or children.
Please add
Code: |
SET outRoot.(XMLNSC.Attribute)msgid = InputRoot.MQMD.CorrelId; |
to both of your two snippets and try it again. If the SET statement fails in the second case, then you have identified the issue. If the Set statement DOESN'T fail in both cases then you have shown that the debugger is useless. Which it is. |
|
Back to top |
|
 |
kimbert |
Posted: Wed Nov 30, 2011 3:03 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
...then you have shown that the debugger is useless. Which it is. |
I can't let that one past without a comment. I know I'm always advising people to take a user trace, but the flow debugger works very well for normal situations, especially since v7. I use it myself unless and until I find that it's not doing the job.
But there are cases where a user trace is essential, and I think this is one of them. |
|
Back to top |
|
 |
|