View previous topic :: View next topic |
Author |
Message |
mfuser Banned
Joined: 01 Mar 2005 Posts: 105 Topics: 58
|
Posted: Thu Sep 28, 2006 7:36 am Post subject: Null Indicator query |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12385 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
|
|