MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to identify a null value

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
venus
Beginner


Joined: 02 Jun 2006
Posts: 16
Topics: 11

PostPosted: Fri Jun 02, 2006 10:36 pm    Post subject: how to identify a null value Reply with quote

question 1:

in my program i coded a select statemnet. in the select iam selecting
a null coloumn. But how can i know that iam selecting a null coloumn.


question 2:

iam writing a batch progrma , which select information from table a and
update table b and c. let us suppose after updating 10000 rows job abends. what i need to do ,to make job running .( it should start updating rows from 10001)
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sat Jun 03, 2006 7:04 am    Post subject: Reply with quote

venus,

1. Use the Null indicators on the selected column. If the value for the column you retrieve is null, DB2 puts a negative value in the indicator variable. or simply check for the SQLCODE -305

Check this link which explains in detail about null indicators

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAPH11/2.1.4.1.4?SHELF=&DT=20010710165542&CASE=

2. Store the last updated key and upon restarting the pgm after abend fetch the data from table A with key > last updated stored key

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sriramla
Beginner


Joined: 22 Feb 2003
Posts: 74
Topics: 1

PostPosted: Mon Jun 05, 2006 9:42 am    Post subject: Reply with quote

Quote:

or simply check for the SQLCODE -305


I would perfer to go with Null Indicator becuase when there are more than 1 columns having null values, null indicator tells which column has nulls. SQL Code -305 tells one or more of the columns are null. But does not give a direct info of exact column (unless we use DSNTIAR / analyse SQLCA structure to get to know the field number in SELECT / FETCH etc.)
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Mon Jun 05, 2006 10:33 am    Post subject: Reply with quote

Venus,

Some more info:
Code:

WORKING-STORAGE SECTION.
01 WS-LITERALS.
   05 ABEND-SQLCODE            PIC S9(09) SIGN LEADING       
                                       SEPARATE DISPLAY.
   05 NULL-IND                 PIC S99 COMP VALUE +0. 
   05 WS-DED-AMT               PIC S9(09)V9(02) COMP-3.
 
******************************************************************
*            EXECUTE SELECT QUERY                                *
******************************************************************
     EXEC SQL                                                     
         SELECT DED_AMT                                   
         INTO   :WS-DED-AMT:NULL-IND                             
         FROM   TAXTABLE                                     
         WHERE    EMPL_SERIAL = :WS-EMPNO                           
     END-EXEC.

EVALUATE SQLCODE                                             
   WHEN 0                                                   
        IF NULL-IND = -1                                     
           DISPLAY 'WS-DED-AMT ' WS-DED-AMT         
        END-IF                                               
   WHEN 100                                                 
        CONTINUE               
   WHEN OTHER                                               
        MOVE 'SELECT FAILED FOR TAXTABLE' TO ABEND-MSG   
        MOVE SQLCODE    TO ABEND-SQLCODE                     
        MOVE WS-EMPNO   TO ABEND-EMPNO                       
        PERFORM 999-ABEND-ERROR THRU 999-ABEND-ERROR-EXIT   
END-EVALUATE. 

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group