MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COBOL Host variable

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Wed Sep 22, 2021 9:21 am    Post subject: COBOL Host variable Reply with quote

Hi
In a file a variable pol-num is declared as 9(16). In DB2 table column is polno declared as decimal(16,0).

When I try to check pol-num in table with select statement I'm getting pol-num as undefined or unusual host variable.

select polno into :ws-pol-num from policy where polno = :pol-num

I declared ws-pol-num pic 9(16).

Where is data incompatibility? any help
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Wed Sep 22, 2021 9:37 am    Post subject: Reply with quote

SRI123,

If the POLNO in DB2 table is defined as DECIMAL, then the COBOL equivalent of that is COMP-3. Check this link which explains the equivalent SQL and COBOL data types

Alternatively you can use DCLGEN to generate the table host variables so that you don't have worry about defining the equivalent data types.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SRI123
Beginner


Joined: 01 Jun 2012
Posts: 18
Topics: 7

PostPosted: Wed Sep 22, 2021 10:21 am    Post subject: Reply with quote

Thanks for reply Kolusu.

In input file field is declared as pic 9(16).

I'm moving this to host variable POLNO PIC S9(16)V USAGE COMP-3 and selecting the statement
select polno into :ws-pol-num from policy where polno = :POLNO

Now i"m getting sqlcode -206 for the table column polno

SQLCODE=-206
SQLSTATE=42703
TOKENS=POLNO
CSECT NAME=DSNXORSO
RDS CODE=-100
Back to top
View user's profile Send private message
haatvedt
Beginner


Joined: 14 Nov 2003
Posts: 66
Topics: 0
Location: St Cloud, Minnesota USA

PostPosted: Wed Sep 22, 2021 1:22 pm    Post subject: Reply with quote

n DB2 the column is defined as decimal, in COBOL the host variable should be usage COMP-3.

Quote:
select polno into :ws-pol-num from policy where polno = :pol-num

I declared ws-pol-num pic 9(16).



NOTICE that you defined "ws-pol-num" but your select statement references ":pol-num" =====> not the same as you cobol variable !!

PS Never use variables defined in the FD / SD section of the code as HOST VARIABLES in a DB2 statement. The reason is that the address of the FD / SD fields changes after every file operation and DB2 only establishes the address of HOST VARIABLES once normally.
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group