Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

UNUSABLE HOST VARIABLE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 70
Location: India

PostPosted: Wed Jan 15, 2014 1:02 pm    Post subject: UNUSABLE HOST VARIABLE
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: 70
Location: India

PostPosted: Wed Jan 15, 2014 1:13 pm    Post subject:
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    Post subject:
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    Post subject:
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: 70
Location: India

PostPosted: Wed Jan 15, 2014 4:34 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us