Joined: 31 Mar 2005 Posts: 436 Location: chennai, India
Generally , compatible COBOL host variable structure to receive the result of a SELECT COUNT(*) is integer type PIC S9(9) USAGE COMP
and agreed it also varies system to system but with signed declaration.
My question is why do we require sign here if we know that count is not going to be negative. For perform varying by -ve's(-1,-2) counters are declared as signed int. Is there any performance efficient related matters for signed delcarations?
It is simple fact that DB2 make use of INTEGER data-type for counting rows and that is reason why we have to make use of S9(9) COMP. Had it been the case that DB2 has used unsigned INTEGER for counting then we would have used 9(9) COMP.
Now why DB2 uses INTEGER (signed) datatype for counting rows that I dont know for sure, becuase I am not DB2 system programmer. I think it is more linked to the CPU instruction compatibility!!