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

Query on SET Db2 Command.


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

New User


Joined: 10 Oct 2006
Posts: 29

PostPosted: Tue Sep 07, 2010 11:30 am
Reply with quote

Hi All,

I wanted to calculate a date which is 27 months old.
I have introduced the below mentioned code in a cobol program.

EXEC SQL
SET :WS-PURGE-DT = WS-PURGE-DB2 - 27 MONTHS
END-EXEC

The variables are defined as below in WS.

05 WS-PURGE-DT PIC X(10).
05 WS-PURGE-DB2 PIC X(10).


But this is not working for me by giving a sqlcode of -171.
If the above code wont work, can somebody help with the correct statement to get the 27 months old date.

Thanks in advance
Ajay.
Back to top
View user's profile Send private message
ajay_udl

New User


Joined: 10 Oct 2006
Posts: 29

PostPosted: Tue Sep 07, 2010 11:32 am
Reply with quote

Hi All,

A small correction in the above mentioned code.
I have missed the colon for host variable

it will look like:

EXEC SQL
SET :WS-PURGE-DT = :WS-PURGE-DB2 - 27 MONTHS
END-EXEC

regards
Ajay
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Sep 07, 2010 2:40 pm
Reply with quote

give you a hint:

db2 knows the data type of a column.
but, db2 has no idea the data type of a host variable.
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 RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts DTL - how to define key with stacked ... TSO/ISPF 3
No new posts LTJ command CA Products 4
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top