View previous topic :: View next topic
|
Author |
Message |
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Hi All,
I have the below query.
EXEC SQL
SELECT (DATE(:WS-DATE) - :WS-DAYS DAYS)
INTO :WS-TEMP-DATE
FROM SYSIBM.SYSDUMMY1
END-EXEC
I am getting pre compile error for the above as
UNDEFINED OR UNUSABLE HOST VARIABLE "WS-DAYS"
I have defined WS-DAYS in 01 level as 9(01).
Am I missing something? |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Got it... WS-DAYS should be X(01) |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Could you post your result if possible?
I was thinking all integer used in the SQL should be declared as PIC S9(9) USAGE COMP. |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
if you just want to subtract some days from the date, you may use this code as your alternative.
Code: |
01 WS-TEMP-DATE PIC 9(08).
01 WS-DATE PIC 9(08) VALUE 20140115.
01 WS-DAYS PIC 9(01) VALUE 5.
COMPUTE WS-TEMP-DATE = FUNCTION DATE-OF-INTEGER (
FUNCTION INTEGER-OF-DATE(WS-DATE) - WS-DAYS)
|
WS-TEMP-DATE value would be 20140110. |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Thanks a lot Suresh...
Yes that's right. I had to change it back to S9(04) Comp.
Let me also try the code you have given. |
|
Back to top |
|
|
|