Sorry, Herb, I guess I can't help after all. I only use DB2 for LUW,
not z/OS. Interestingly, I do get an error with sqlstate 42601
referencing an unexpected token "BEGIN" on the original code you posted,
which is resolved on my system by adding "ATOMIC". With your new code,
I no longer get this error, so I guess this must be specific to z/OS.
(I did get a data type incompatibility error, and had to change the
V_YEAR declaration to be an INT instead of CHAR(4) to match the output
of the YEAR function.)
In other words, the following works fine for me on DB2 LUW.
Sorry, I don't know why it's not working for you on z/OS:
CREATE FUNCTION test( P_CTY_ST_C VARCHAR(10), P_DATE DATE )
RETURNS CHARACTER(3)
-- VERSION V1
DETERMINISTIC
NO EXTERNAL ACTION
BEGIN ATOMIC
DECLARE OUT_TIME_ZONE CHAR(3);
-- DECLARE V_YEAR CHAR(4);
DECLARE V_YEAR INT;
DECLARE V_BEG_D DATE;
DECLARE V_END_D DATE;
DECLARE V_STD_TIME_DVTN_H SMALLINT;
DECLARE V_ADV_TIME_DVTN_H SMALLINT;
SET V_YEAR = YEAR(P_DATE);
RETURN OUT_TIME_ZONE;
END @
DROP FUNCTION TEST @