ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Environment NULL values

Post new topic  Reply to topic
 Environment NULL values « View previous topic :: View next topic » 
Author Message
Ramphart
PostPosted: Wed Dec 22, 2004 1:46 pm    Post subject: Environment NULL values Reply with quote

Disciple

Joined: 21 Jul 2004
Posts: 150
Location: South Africa, JHB

- I'm using WMQI 2.1 CSD 07 on Windows 2000.

Code 1
Code:
IF Environment.Vars.Value <> 'Z' THEN
 SET a = 1;
END IF;


Code 2
Code:
IF Environment.Vars.Value IS NULL THEN
 SET a = 1;
END IF;



Info
- The Environment.Vars.Value does not exist when the code runs (i.e. it is NULL)
- When I use Code 1 above, the Set a = 1 statement never executes.
- When I use Code 2 above, the Set a = 1 executes.
- How come Code 1 does not work? I would have thought that since NULL <> 'Z' Code 1 should also work

Regards
_________________
Applications Architect
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Dec 22, 2004 3:57 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

As the Value field does not exist, the left oprand of the <> operator resolves to NULL, therefore at this time it is as if you had written:

IF NULL <> 'Z' THEN ...

However, the result of any comparison of NULL with something else is NULL. Therefore the result of the above is NULL, so it is as if you had written:

IF NULL THEN...

The result of this can only be NULL not TRUE so the THEN block will not execute.


It is exactly for situations like this that (E)SQL has the IS NULL construct, as you have found.


Hope this helps.
_________________
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
View user's profile Send private message
Ramphart
PostPosted: Wed Dec 22, 2004 9:33 pm    Post subject: Reply with quote

Disciple

Joined: 21 Jul 2004
Posts: 150
Location: South Africa, JHB

I makes sense now. So I guess to be on the safe side one should really code as follows:

Code:
IF Environment.Vars.Value <> 'Z' OR Environment.Vars.Value IS NULL THEN
 SET a = 1;
END IF;

_________________
Applications Architect
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Dec 23, 2004 4:26 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Be aware, as well, that when working with Environment, you may have a field that is NULL in the database that ends up being 'NULL' in Environment instead of NULL.

But that should be covered in your code, because 'NULL' is not NULL and is <> 'Z'.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Environment NULL values
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.