| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

12-14-10, 02:43
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 4
|
|
NULL value check in DB2
|
|
Hi,
I have a requirement to check whether IS [NOT] NULL function like anything in DB2, to check whether it is NULL
in oracle we can use
SELECT a FROM abc
WHERE IS NOT NULL
is there any thing similar in DB2 which can be used in a WHERE clause
please help
Saiju
|
|

12-14-10, 05:52
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
Originally Posted by ssaiju
is there any thing similar in DB2 which can be used in a WHERE clause
|
yes, you can do the same in DB2
however, your oracle example is not quite right --
Quote:
SELECT a FROM abc
WHERE IS NOT NULL
|
this is incorrect in any database system
it should be like this --
Code:
SELECT a FROM abc
WHERE something IS NOT NULL

|
|

12-14-10, 06:06
|
|
Registered User
|
|
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
|
|
|
|
My tutor once said: "think of that little river in austria: the INN" when I coded someting like "not is null" which was rejected as valid SQL 
|
|

12-14-10, 06:13
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 4
|
|
thanks for the reply & correction
SELECT a FROM abc
WHERE smething IS NOT NULL
is fetching NULL values as well in 9.7.
Is there any specific setting needs to be done ..?
|
|

12-14-10, 06:53
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
what is the exact query you ran, please?
|
|

12-14-10, 08:02
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 4
|
|
The below query returns null values in DB2 9.7
select NEG_INSTR_SER_NO from journl_entry_item where NEG_INSTR_SER_NO is not null
Any other alternative to check null values ..?
|
|

12-14-10, 08:25
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Are you confusing empty strings with nulls, may be?
|
|

12-14-10, 08:34
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
Originally Posted by n_i
Are you confusing empty strings with nulls, may be?
|
not his fault, really, coming from oracle which doesn't know the difference 
|
|

12-14-10, 08:37
|
|
Registered User
|
|
Join Date: Dec 2010
Posts: 4
|
|
the same dataset behaves differently in oracle and DB2 for the same query ..
i am just trying to find the difference in implementation
How the DB2 differentiate an empty string compared to oracle ..?
|
|

12-14-10, 09:31
|
|
Registered User
|
|
Join Date: Jun 2007
Location: germany
Posts: 96
|
|
an empty string (null string/string with length zero) is = '' (or = "")
null is a column attribute. a column may contain a
'null string/empty string/varchar length 0/fixed length all spaces'
but if a column is null, then there is no value/data to check, you check the attribute,
which in db2 is IS COLUMN NULL.
__________________
Dick Brenholtz, Ami in Deutschland
|
|

12-14-10, 10:20
|
|
Registered User
|
|
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
|
|
do you mean you loaded data from a file into a DB2 table and you are now trying to find records that are not null and you are finding records that should be null? If that is the case, then you should look at your load control statement to see if the null indicator value was identified for the load process.
Dave
|
|

12-14-10, 11:50
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,198
|
|
In Oracle, testing = '' (two single quotes) is the same as testing for null. This is not in accordance with ANSI SQL standards and is not supported by normal DB2 syntax, however, I am not sure about Oracle compatibility mode in DB2 9.7.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|