e.g.
SELECT CASE
WHEN YEAR(T1.AC_START_DT) =
:WS-AC-START-DT-YY
AND MONTH(T1.AC_START_DT) =
:WS-AC-START-DT-MM
THEN DATE(T1.AC_START_DT) - 1 DAY
ELSE :WS-SOME-OTHER-DT
END AS FROMDT
FROM Table1 T1
WHERE ACC_NO = :WS-AC-NO
WHEN YEAR(T1.AC_START_DT) =
:WS-AC-START-DT-YY
AND MONTH(T1.AC_START_DT) =
:WS-AC-START-DT-MM
THEN DATE(T1.AC_START_DT) - 1 DAY
ELSE :WS-SOME-OTHER-DT
END AS FROMDT
FROM Table1 T1
WHERE ACC_NO = :WS-AC-NO
I am getting errors such as the host variables WS-AC-START-DT-YY and WS-AC-START-DT-MM are not defined correctly. So, I don't know what is the correct way of defining such host variables. I am defining them as 9(04) comp.
Also is there any other way to do this ? Once this query goes through my DBAs, I know they will reject it as they do not like me using YEAR and MONTH (or even LAST_DAY) functions as it slows down the performance.
P.S. the query given above is a small part of a bigger query, so it cannot be done in COBOL also. I have to do it somehow in db2.
Any suggestion would be really grateful.
thanks a lot.