Page 1 of 1

COBOL Host variable

PostPosted: Wed Sep 22, 2021 7:55 pm
by SMRAO123
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

Re: COBOL Host variable

PostPosted: Wed Sep 22, 2021 11:40 pm
by chaat
In DB2 the column is defined as decimal, in COBOL the host variable should be usage COMP-3.

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.