I need help with an issue regarding date returns in a CURSOR in DB2 for LUW.
The Dt_Noformat field returns an incorrect date, while the Dt_Format field returns the date correctly.
This problem occurs only when using the cursor. The query runs without any issues when executed on its own.
Has anyone else encountered this problem? I think that is occuring implicit converstion of date, but i would like to know why.
The simplified code is as follows:
CREATE OR REPLACE PROCEDURE TEST_DATE_FORMAT()
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC TEST_DATE_FORMAT
BEGIN
DECLARE CUR CURSOR WITH RETURN FOR
SELECT
CURRENT_DATE AS DT_NOFORMAT
,VARCHAR_FORMAT(CURRENT_DATE, 'YYYY-MM-DD') AS DT_FORMAT
FROM
SYSIBM.SYSDUMMY1;
OPEN CUR;
END;
The return is like this:
| DT_NOFORMAT | DT_FORMAT |
|---|---|
| 2027-12-04 | 2026-04-24 |
I'd appreciate it if anyone could help.