IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

UNUSABLE HOST VARIABLE


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Wed Jan 15, 2014 1:02 pm
Reply with quote

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
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Wed Jan 15, 2014 1:13 pm
Reply with quote

Got it... WS-DAYS should be X(01)
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Jan 15, 2014 1:27 pm
Reply with quote

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
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Wed Jan 15, 2014 1:41 pm
Reply with quote

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
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Wed Jan 15, 2014 4:34 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts access the last host command CLIST & REXX 2
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top