How can u retrieve the null values in a field?



IBM's flagship relational database management system

How can u retrieve the null values in a field?

Postby ragur.satheesh » Mon Dec 13, 2010 12:21 pm

How can u retrieve the null values in a field?
ragur.satheesh
 
Posts: 17
Joined: Thu Jul 22, 2010 12:34 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How can u retrieve the null values in a field?

Postby GuyC » Mon Dec 13, 2010 2:13 pm

null-indicator variables
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times

Re: How can u retrieve the null values in a field?

Postby Selvaraj » Thu Dec 23, 2010 2:03 pm

Code dis query select * from table where column is null
Selvaraj
 
Posts: 9
Joined: Wed Dec 22, 2010 9:09 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How can u retrieve the null values in a field?

Postby dick scherrer » Fri Dec 24, 2010 1:25 am

Hello,

Keep in mind that you can determine if a column is NULL using the null-indicator variable -but also keep in mind that there is No Such Thing as a NULL VALUE in the column. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: How can u retrieve the null values in a field?

Postby chandrababun » Wed Dec 29, 2010 3:32 pm

MOVE ZEROES   TO WS-LASTNAME-IND

   EXEC SQL
      SELECT LASTNAME
        INTO :WS-LAST :WS-LASTNAME-IND
        FROM  EMPLOYEE
       WHERE  EMPNO = :WS-EMPNO
   END-EXEC.
   IF WS-LASTNAME-IND < ZEROES
      .....
   END-IF.


WS-LASTNAME-IND --- Need to define the null indicator variable with s9(04) comp in Working storage

We can test the indicator variable WS-LASTNAME-IND for a negative value. If it is negative, the corresponding value in the host variable WS-LAST is NULL, and therefore, the contents of WS-LAST can be disregarded.

It is not necessary to initialize the WS-LASTNAME-IND before the SQL statement. DB2 will place a negative value or zero based on the contents of the column (NULL or NOT). But it is good programming practice to initialize all host variables and indicator variables.

If the indicator variable is not specified and a NULL value is returned, DB2 will flag an error condition and the value in the WS-LAST column is undefined and unpredictable.
chandrababun
 
Posts: 3
Joined: Wed Oct 20, 2010 2:36 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post