Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric Data types and SQL

Status
Not open for further replies.

iswa

IS-IT--Management
Dec 7, 2006
2
GB
Running DB2 v8.2. I have a field defined as numeric (15,0). In my cobol program I define the field as S9(15)v comp-3. When I try to access this field using embedded SQL, the cursor fetch statement returns the following message -
--- error report ---
ERROR occurred : Fetch Cursor
SQLCODE : -00304
SQL0304N A value cannot be assigned to a host variable because the
value is not within the range of the host variable's data type.
SQLSTATE=22003
SQLSTATE 22003: A numeric value is out of range.

If I define the field as s9(7)v99 comp-3, the error goes away, but the data is incorrect, because it maps the field as 5 bytes, not 8.

How do I get round this.

The box is hp-ux, the compiler is acucobol and the pre-compiler is the ibm pre-compiler
 
I don't think that ANY numeric SQL data type is compatible with COMP-3 ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Try a DB2 or an SQL forum. Not everyone knows what some field description in DB2 means or how that affects SQL. No such thing as SQL in Standard COBOL.

If you do not like my post feel free to point out your opinion or my errors.
 
From the IBM help files:

SMALLINT
(500 or 501)
01 name PIC S9(4) COMP-5. 16-bit signed integer

INTEGER
(496 or 497)
01 name PIC S9(9) COMP-5. 32-bit signed integer

BIGINT
(492 or 493)
01 name PIC S9(18) COMP-5. 64-bit signed integer

DECIMAL(p,s)
(484 or 485)
01 name PIC S9(m)V9(n) COMP-3. Packed decimal


Hope this helps

Brian
 
iswa,

I've not seen NUMERIC used as a DB2 data type and would use DECIMAL(15, 0) instead. Your Cobol definition should be PIC S9(15)V USAGE COMP-3.

Marc
 
OK , problem solved.

In precompiling under windows, the sql-host-var-length is wrong. Working out a solution now.


Thanks for all the replies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top