View previous topic :: View next topic |
Author |
Message |
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Wed Sep 22, 2021 9:21 am Post subject: COBOL Host variable |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Wed Sep 22, 2021 9:37 am Post subject: |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
SRI123 Beginner
Joined: 01 Jun 2012 Posts: 18 Topics: 7
|
Posted: Wed Sep 22, 2021 10:21 am Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
haatvedt Beginner
Joined: 14 Nov 2003 Posts: 66 Topics: 0 Location: St Cloud, Minnesota USA
|
Posted: Wed Sep 22, 2021 1:22 pm Post subject: |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|