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 

Null Indicator query

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


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Thu Sep 28, 2006 7:36 am    Post subject: Null Indicator query Reply with quote

Members,

I have a DB2 query which i tested in QMF and i was getting values properly for a tax field which was a sum.The same query is coded in the program with null indicator variable as :
Code:

05 NULL-IND                 PIC S99 COMP VALUE +0.
05 NULL-IND-E               PIC ZZ-.
05 WS-TAX                   PIC S9(09)V9(02) COMP-3.

     EXEC SQL                                                     
         SELECT SUM(TAX)                                     
         INTO   :WS-TAX:NULL-IND                             
         FROM   TAXTABLE                                       
         WHERE  EMPL_SERIAL = :WS-EMPNO                           
     END-EXEC.                                                   

MOVE     NULL-IND    TO NULL-IND-E.
DISPLAY 'NULL-IND-E ' NULL-IND-E.

EVALUATE SQLCODE                                             
   WHEN 0                                                   
        IF NULL-IND = -1                                     
           DISPLAY 'TAX WAS NEGATIVE VALUE  '
           DISPLAY 'WS-TAX                  ' WS-TAX       
        ELSE                                                 
           DISPLAY 'TAX WAS POSITIVE VALUE  '
           DISPLAY 'WS-TAX                  ' WS-TAX       
        END-IF                                               
   WHEN 100                                                 
           DISPLAY 'ROW NOT FOUND           '
   WHEN OTHER
           PERFORM ABEND-ERROR
END-EVALUATE.

When i had run the program i got the output:
Code:

NULL-IND-E: 1-
TAX WAS NEGATIVE VALUE


My question is i got the positive value when i run the query in QMF and the amount was positive which means SQL code is 0 and then the if condition was checked ,why is the Null Indicator value -1 when the value is positive amount.I am not clear when the query retrieved positive correctly why should it have -1 in the Null Indicator.Please help me out in clearing the concept of Null Indicator.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Sep 28, 2006 8:01 am    Post subject: Reply with quote

mfuser,

It is shame that I had to spoon feed. I guess there is no point of reminding you to search the forum for "null indicator". Check this

http://www.mvsforums.com/helpboards/viewtopic.php?t=6521&highlight=null+indicator

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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