Author |
Message
|
klabran |
Posted: Thu Oct 19, 2006 2:37 pm Post subject: Compiler change from v5 to v6 broker for references? |
|
|
 Master
Joined: 19 Feb 2004 Posts: 259 Location: Flagstaff AZ
|
It seems that the v6 broker compilation works differently with references than the v5 broker....
Below is my code snippet:
Code: |
DECLARE refBookID REFERENCE TO Body.cjs_Report.Booking.Suspect.BookingAgencyRecordID."j:ID";
--Check if this is a booking. Do not want arrests checked.
IF refBookID IS NOT NULL AND TRIM(' ' FROM refBookID) <> 'CNO0' THEN
|
My incoming data is XML.
In v5 of the broker if "j:ID" was filled in then refBookID was the value of "j:ID"
In v5 of the broker if "j:ID" is missing then refBookID is NULL.
In v6 of the broker if "j:ID" was filled in then refBookID was the value of "j:ID". This is good....
In v6 of the broker if "j:ID" is missing then refBookID returns the entire body (tree)...???
This change is causing my IF clause to fail now....
Is this right or am I missing something???
Thanks,
Kevin |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Oct 19, 2006 7:36 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
This is right .
What you are missing is
Code: |
IF LASTMOVE(reference) THEN
-- the move was successful the reference is valid
ELSE
/* the move was not successful and the reference probably still contains the previous value. */
END IF; |
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
klabran |
Posted: Fri Oct 20, 2006 6:12 am Post subject: |
|
|
 Master
Joined: 19 Feb 2004 Posts: 259 Location: Flagstaff AZ
|
Thanks fjb_saper!
Changed the IF to
Code: |
IF LASTMOVE(refBookID) AND TRIM(' ' FROM refBookID) <> 'CNO0' THEN
|
All is well again!  |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 20, 2006 7:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can also check if FIELDNAME(reference) is NULL. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Yaroslav |
Posted: Fri Oct 20, 2006 10:38 am Post subject: |
|
|
Novice
Joined: 28 Sep 2006 Posts: 12 Location: Russia
|
jefflowrey wrote: |
You can also check if FIELDNAME(reference) is NULL. |
Hi, jefflowrey!
I am sorry , but your advice may be used only for static reference, not for dynamic. _________________ IBM Certified Solution Designer WebSphere MQ V6.0
IBM Certified Solution Developer WebSphere Message Broker V6.0 |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 20, 2006 10:47 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yaroslav - I guess I don't understand what you mean.
A variable of REFERENCE type only ever points to one thing at a time.
FIELDNAME is documented to return NULL if it's given a NULL input. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 20, 2006 3:26 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jefflowrey wrote: |
Yaroslav - I guess I don't understand what you mean.
A variable of REFERENCE type only ever points to one thing at a time.
FIELDNAME is documented to return NULL if it's given a NULL input. |
I believe the point here is that he is not setting any value to the field but just walking the input tree.
Now if the field he is trying to walk to does not exist on the tree the value of the reference is not null but some tree structure... The value of LASTMOVE(reference) however is FALSE.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 20, 2006 6:00 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, I think if I do a MOVE off the end of the tree, then the reference will still be NULL as far as FIELDVALUE is concerned.
But, on the other hand, I haven't actually tested it, so I'm probably wrong.
On the third hand, any time you do a MOVE you should absolutely do a LASTMOVE. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
klabran |
Posted: Sat Oct 21, 2006 11:38 am Post subject: |
|
|
 Master
Joined: 19 Feb 2004 Posts: 259 Location: Flagstaff AZ
|
They both work properly.
Code: |
IF FIELDNAME(refBookID) IS NOT NULL AND TRIM(' ' FROM refBookID) <> 'CNO0' THEN
|
Code: |
IF LASTMOVE(refBookID) AND TRIM(' ' FROM refBookID) <> 'CNO0' THEN
|
I am not moving at all in this scenario except of course when the reference is being created in the variable declaration statement. I was simply setting a reference for ease of coding (much easier to type refBookID instead of body.blah.blah.blah.blah .  |
|
Back to top |
|
 |
mgk |
Posted: Sun Oct 22, 2006 8:54 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi,
You should really do a LASTMOVE after the DECLARE of a REFERENCE if you cannot be sure that the place you are telling the reference point to exists.
A REFERENCE that is DECLAREd to point to somewhere that does not exist is made to point to the root of the tree you were trying to make it point within, and a LASTMOVE after the DECLARE will return FALSE. _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
|