COBOL Host variable



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COBOL Host variable

Postby SMRAO123 » Wed Sep 22, 2021 7:55 pm

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
SMRAO123
 
Posts: 12
Joined: Thu Oct 28, 2010 12:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL Host variable

Postby chaat » Wed Sep 22, 2021 11:40 pm

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.
chaat
 
Posts: 27
Joined: Sun Aug 16, 2009 11:07 pm
Location: St. Cloud, Minnesota
Has thanked: 0 time
Been thanked: 1 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post