CREATE FUNCTION RTWO(ALPHA DOUBLE)
RETURN ROUND(ALPHA, 2);
Next, you run a select statement like below.
select rtwo(393.996) from sysibm.sysdummy1
You will probably have the result::-
which is not exactly the result we want. The expected result is actually 394.00 with 2 decimal points.
Below is the modified code to produce the expected result.
CREATE OR REPLACE FUNCTION INCREMENT(BETA DOUBLE)
DECLARE ALPHA DECIMAL(15,2);
SET ALPHA = ROUND(CAST(BETA AS DECIMAL(15,3)),2);
Now, if do the same select statement, select rtwo(393.996) from sysibm.sysdummy1 , you will be able to produce the expected result.