Author |
Message
|
VIVEK MOHAN |
Posted: Sun Feb 24, 2013 11:06 pm Post subject: Difference between the Two statements |
|
|
Newbie
Joined: 21 Feb 2013 Posts: 5
|
Hello All,
I am using both the below statements to serve my purpose but i don't know which statement is effective and why??
DECLARE ref1 REFERENCE TO OutputRoot.XMLNSC.Order.Summary.CustomerDetails;
set ref1=OutputRoot.XMLNSC.Order.Summary.CustomerDetails; |
|
Back to top |
|
 |
Veera B |
Posted: Sun Feb 24, 2013 11:44 pm Post subject: |
|
|
Voyager
Joined: 16 Jan 2013 Posts: 76
|
first be clear on what you want to do ..
The first statement is to create a reference variable, like a pointer ..
the second statement is to set a value to ... a variable, xml element etc ...
But what you are doing here is wrong ... you are trying to set value to a reference ...
the purpose of taking a refernce is to make the code more efficient and easy to write ..
for example from your code , i would do this :-
Declare ref1 Reference to OutputRoot.XMLNSC.Order.Summary;
Set Element1 = ref1 .CustomerDetails;
Set Element2 = ref1 .CustomerSomething ....
Please go trough the samples provided carefully and also go trough the info center for solving doubts... |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 25, 2013 3:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
@veeraB You are treating in your example the reference as if it were a ref to InputRoot. The OP clearly stated that it was a ref to OutputRoot...
The second statement given by the OP makes no sense. It is already covered by the first statement declaring the ref.
However you should always check LASTMOVE after assigning or moving a reference...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
longng |
Posted: Mon Feb 25, 2013 10:54 am Post subject: |
|
|
Apprentice
Joined: 22 Feb 2013 Posts: 42
|
fjb_saper wrote: |
@veeraB You are treating in your example the reference as if it were a ref to InputRoot. The OP clearly stated that it was a ref to OutputRoot...
The second statement given by the OP makes no sense. It is already covered by the first statement declaring the ref.
However you should always check LASTMOVE after assigning or moving a reference...
Have fun  |
I agree that the second statement makes no sense, i.e. Assigning a value in the variable to itself! That is because ref1 points to OutputRoot.XMLNSC.Order.Summary.CustomerDetails.
For checking the LASTMOVE, it would be valid to use only to operations related to reference variables, e.g.
Code: |
DECLARE ref1 REFERENCE TO OutputRoot.XMLNSC.Order.Summary;
MOVE ref1 to OutputRoot.XMLNSC.Order.Summary.CustomerDetails;
IF (LASTMOVE (ref1)
-- Successful move!
SET ref1 = 'Jane Doe';
-- Equivalent to SET OutputRoot.XMLNSC.Order.Summary.CustomerDetails = 'Jane Doe';
ELSE
-- Something wrong, the ref1 is not valid for use.
END IF;
|
For clarity, the SET statement does not change the reference variable itself, it only affects the contents of the variable pointed to by the reference. |
|
Back to top |
|
 |
Veera B |
Posted: Tue Feb 26, 2013 6:54 am Post subject: |
|
|
Voyager
Joined: 16 Jan 2013 Posts: 76
|
fjb_saper wrote: |
@veeraB You are treating in your example the reference as if it were a ref to InputRoot. The OP clearly stated that it was a ref to OutputRoot...
Have fun  |
Oops .. posted in a hurry .. sorry .. solution was in my brain but didn't come out the way i wanted ... |
|
Back to top |
|
 |
|