View previous topic :: View next topic
|
Author |
Message |
Sikkandhar
New User
Joined: 03 Dec 2007 Posts: 61 Location: Bangalore
|
|
|
|
Hi,
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'
Thanks
Sikkandhar |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Code: |
---------+---------+---------+---------+---------+---------+---------+---------+
SELECT 00000199
DATE (CURRENT DATE) - DATE ('0001-01-01') 00000299
FROM SYSIBM.SYSDUMMY1; 00000399
---------+---------+---------+---------+---------+---------+---------+---------+
---------+---------+---------+---------+---------+---------+---------+---------+
20111028, |
Is the output you get
What is the business reason here at first place to subtract a year , a month and a day from a given date??
Can you try ?
Code: |
SELECT
DATE (CURRENT_DATE) - DATE ('0001-01-01')
INTO :VAR1
FROM SYSIBM.SYSDUMMY1; |
|
|
Back to top |
|
|
Sikkandhar
New User
Joined: 03 Dec 2007 Posts: 61 Location: Bangalore
|
|
|
|
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 |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Sikkandhar,
Read the Error message properly.
Have you verified the table definations.
Quote: |
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.
Thanks,
Sushanth |
|
Back to top |
|
|
Sikkandhar
New User
Joined: 03 Dec 2007 Posts: 61 Location: Bangalore
|
|
|
|
Thanks Sushanth.
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 |
|
Back to top |
|
|
|