Below is a section of a stored procedure that I am currently writing.
(On db2 7.1 z/os)
BUDGETEDUNITS_0, BUDGET_MONTHS, and MTHLYUNITS_0 are defined as SMALLINT.
SELECT INT(ROUND(DEC(BUDGETEDUNITS_0/BUDGET_MONTHS,5,2),0))
INTO MTHLYUNITS_0
FROM SYSIBM.SYSDUMMY1;
ELSE SET MTHLYUNITS_0 = 0;
END IF;
***********************************************
In testing I have found the following results
a)
SELECT INT(ROUND(DEC(707/23,5,2),0))
AS MTHLYUNITS_0
FROM SYSIBM.SYSDUMMY1;
30
b)
SELECT INT(ROUND(DEC(707/23.00,5,2),0))
AS MTHLYUNITS_0
FROM SYSIBM.SYSDUMMY1;
31
c)
SELECT INT(ROUND(DEC(707/23.0,5,2),0))
AS MTHLYUNITS_0
FROM SYSIBM.SYSDUMMY1;
31
1) Why am I receivng a difference in responses? Shouldn't I also receive 31 for a?
2) When dividing does the dividend and divisor have to be defined the same?
ex: smallint/smallint, int/int, etc