Author |
Message
|
sarat |
Posted: Sun May 31, 2009 11:56 pm Post subject: If Value is blank for CREATE LAST CHILD, should not populate |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
Hi Everyone,
I need help while creating lastchild...
The below code working fine.
Code: |
CREATE LASTCHILD OF outRef AS OUTref NAMESPACE xxxns NAME 'COMMON' VALUE THE(SELECT ITEM X.Value FROM xyzRef.ABC[] AS X WHERE X.Name = 'one'); |
Am creating same child 'COMMON' 10 times.
Now, the problem is.. I need to create the child if and only if the X.Value is not blank. If it's blank, I should not populate the corresponding 'COMMON'
I've tried with NULL and NULLIF .. But no luck... Please give me some suggestion.
With Regards,
Sarat. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 01, 2009 12:04 am Post subject: Re: If Value is blank for CREATE LAST CHILD, should not popu |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sarat wrote: |
Now, the problem is.. I need to create the child if and only if the X.Value is not blank. If it's blank, I should not populate the corresponding 'COMMON'
I've tried with NULL and NULLIF .. But no luck... Please give me some suggestion.
|
Will the field be blank, or will the field be NULL? If it's blank then testing for NULL will not give you the results you want (obviously enough!) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sarat |
Posted: Mon Jun 01, 2009 12:11 am Post subject: |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
Hi Vitor,
Tx for the response..
I mean to say the value is blank _________________ With Regards,
Sarat. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 01, 2009 12:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sarat wrote: |
I mean to say the value is blank |
Then I stand by my assertion that neither NULL nor NULLIF will correctly detect blanks, though both are storming at detecting NULLs!
You'll need to replace the NULL test in whatever code you've constructed with a test for blanks. AFAIK the construction
Code: |
IF XYZRef.X IS NULL |
can't simply be replaced with
Code: |
IF XYZRef.X IS BLANK |
but you get the idea _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sarat |
Posted: Mon Jun 01, 2009 12:45 am Post subject: |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
Under XYZRef, there wil be Name and Value pair.
<XYZ>
<Name>one</Name>
<Value></Value>
</XYZ>
<XYZ>
<Name>two</Name>
<Value>123</Value>
</XYZ>
Like this... _________________ With Regards,
Sarat. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 01, 2009 12:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
So I extend my original question: is the field blank, is the field NULL, is the field not present or is the field present but childless?
Work out the various permutations of the field contents, then test apprpriately. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sarat |
Posted: Mon Jun 01, 2009 1:17 am Post subject: |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
Vitor,
This can be done in other way...
either using FOR loop and check each and every Name and Value combination is present.. If present the create last child..
Else another solution is.. Set the value to an Environment variable, and check if that's not blank then create last child..
But I want to minimal the code .. Is there any chance to get this thing done in other way? _________________ With Regards,
Sarat. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 01, 2009 1:57 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
If it's simply a question of all Value children with actual values being COMMON, then I would expect something like:
Code: |
SELECT SELECT ITEM X.Value FROM xyzRef.ABC[] AS X WHERE X.Value IS NOT NULL |
(untested, written from memory, etc)
to work.
What happened with that? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
sarat |
Posted: Mon Jun 01, 2009 2:05 am Post subject: |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
No Luck Vitor ...
Coz.. CREATE LAST CHILD creating the element with blank..(I guess) _________________ With Regards,
Sarat. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jun 01, 2009 2:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
sarat wrote: |
Coz.. CREATE LAST CHILD creating the element with blank..(I guess) |
Take a user trace and remove guesswork. See what this "blank" element is actually being interpreted as. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 01, 2009 3:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You can also test if the fieldlength is > 0.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sarat |
Posted: Mon Jun 01, 2009 4:16 am Post subject: |
|
|
 Centurion
Joined: 29 Jun 2005 Posts: 136 Location: India
|
Ok.. First it's creating the child and trying to assign the value..
If not found, leaving the child as it's..
Got the solution at last..
Code: |
CREATE LASTCHILD OF outRef AS OUTref NAMESPACE xxxns NAME 'COMMON'
SET OUTref =THE(SELECT ITEM X.Value FROM xyzRef.ABC[] AS X WHERE X.Name = 'one' AND X.Value <>''); |
Tx for all you support _________________ With Regards,
Sarat. |
|
Back to top |
|
 |
|