|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
NULL vs. NULL in Environment or OutputRoot |
« View previous topic :: View next topic » |
Author |
Message
|
jefflowrey |
Posted: Wed Mar 05, 2003 2:07 pm Post subject: NULL vs. NULL in Environment or OutputRoot |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm getting some strange results when retrieving NULL values from a database.
Here's a simple example.
Code: |
set Environment.Variables.DB.NullField[]= (select T.nullField from Database.test_table as T);
set Environment.Variables.Test.Value = NULL;
Set OutputRoot.XML.Test.Value = Environment.Variables.Test.Value;
set Environment.Variables.Test.Result.AgainstMissing = (InputRoot.XML.NoSuchTag is NULL);
set Environment.Variables.Test.Result.AgainstEnvironment = (Environment.Variables.Test.Value IS NULL);
set Environment.Variables.Test.Result.AgainstOutput = (OutputRoot.XML.Test.Value IS NULL);
set Environment.Variables.Test.Result.AgainstDBNullInEnv = (Environment.Variables.DB.NullField[1] IS NULL);
set OutputRoot.XML.Test.DBValue = Environment.Variables.DB.NullField[1];
set Environment.Variables.Test.Result.AgainstDBNullInOutput = (OutputRoot.XML.Test.DBValue IS NULL); |
This ESQL generates the following in a trace file for a simple message of <Test><Value>test</Value></Test>
Code: |
Environment
(
(0x1000000)Variables = (
(0x1000000)DB = (
(0x1000000)NullField = (
(0x3000000)nullField = NULL
)
)
(0x1000000)Test = (
(0x1000000)Result = (
(0x3000000)AgainstMissing = TRUE
(0x3000000)AgainstEnvironment = TRUE
(0x3000000)AgainstOutput = TRUE
(0x3000000)AgainstDBNullInEnv = TRUE
(0x3000000)AgainstDBNullInOutput = FALSE
)
)
)
)
Root
(
(0x1000010)XML = (
(0x1000000)Test = (
(0x1000000)DBValue = (
(0x1000000)nullField = (
(0x2000000) = NULL
)
)
)
)
) |
So, the NULL value returned from the database is still considered a NULL value, UNTIL I copy it out of the Environment and into the OutputRoot. At that point, it is no longer something that IS NULL returns true for. The trace function still reports it as NULL. For values populated with the ESQL NULL keyword, there's no change.
Has anyone else seen this? Is this likely to be an artifact of the database I'm using? |
|
Back to top |
|
 |
EddieA |
Posted: Thu Mar 13, 2003 7:39 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Jeff,
I can't find the reference I had at the moment, but I'll post it when (if) I find again.
Basically what it boils down to is which tree you propogate with the SELECT. If it's a 'true' XML tree, the InputRoot.XML or the OutputRoot.XML then the parser restrictions force the filed to be created with a VALUE of 'NULL'. That means that any empty column/missing row will still generate the Tags and put a character string of NULL in them.
If you use the (Local)Environment trees, then these are not 'true' XML. They are maintained by WMQI as a series of name/value pairs. In this case, if the column/row doesn't exist, then WMQI either doesn't create the Tag or creates it with a NULL value (not a character string). Can't remember which (old age creeping in).
So, when you check for a returned value, you need quotes around the NULL in the Input/Output trees and NO quotes in the Environment trees.
Hope that helps.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 13, 2003 8:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Actually, I got an explanation from Matt Lovett on the ibm wmqi newsgroup.
I'll summarize here. What EddieA says is correct. Copying a null value from the Environment into an XML message causes it to be converted from a NULL value into the character string 'NULL'.
Comparing against a NULL value is done using "is NULL". Comparing against the character 'NULL' is done using " ='NULL' ". |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|