I have the sql in Cobol DB2 program which gives -304 as SQLCODE
Code:
EXEC SQL
SET :VAR1 =
DATE (CURRENT DATE) - DATE (:VAR2)
END-EXEC
Where VAR2 has a value '0001-01-01'. The above query errors out with Sqlcode -304.
If i execute the same query in SPUFI, am getting the result. It is not erroring out.
Code:
SELECT
DATE (CURRENT_DATE) - DATE ('0001-01-01')
FROM SYSIBM.SYSDUMMY1;
I checked in net and few forums say that '0001-01-01' is a valid date in DB2. Am not sure then why my Cobol Program errors out with SQLCODE -304 when i feed the date as '0001-01-01'
---------+---------+---------+---------+---------+---------+---------+---------+
SELECT 00000199
DATE (CURRENT DATE) - DATE ('0001-01-01') 00000299
FROM SYSIBM.SYSDUMMY1; 00000399
---------+---------+---------+---------+---------+---------+---------+---------+
The Input date should not exceed specific limit when compared with the Current date.
In one of the cases, the Input date fed was '0001-01-01'. This date should have ideally returned 20111028 (which is beyond a specific limit as per Business Rules). Instead it returns SQLCODE -304
Tried with below code also
Code:
SELECT
DATE (CURRENT DATE) - DATE (:VAR2)
INTO :VAR1
FROM SYSIBM.SYSDUMMY1
Where VAR2 has the value '0001-01-01'.
It is still giving me SQLCODE -304
Programmer Response: Verify that table definitions are current, and that
the host variable has the correct data type. See the explanation for
SQLCODE -405 for ranges of SQL data types.
Show us how the :VAR1 is defined in working-storage section.
I was able to resolve the error. I had defined VAR1 as S9(04) comp. The parameter that was about to be set is beyond the range. Changed the declaration to S9(09) comp and it worked fine