Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Numeric Data types and SQL

Numeric Data types and SQL

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: 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

RE: Numeric Data types and SQL

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

RE: Numeric Data types and SQL

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.

RE: Numeric Data types and SQL

have you tried without the "V" at the end?


Frederico Fonseca
SysSoft Integrated Ltd

RE: Numeric Data types and SQL

From the IBM help files:

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

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

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

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

Hope this helps


RE: Numeric Data types and SQL


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.


RE: Numeric Data types and SQL

OK , problem solved.

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

Thanks for all the replies.

RE: Numeric Data types and SQL

from yourlast reply seems that you are declaring the variable inside the "declare section".
Try do it outside of it if that is the case.


Frederico Fonseca
SysSoft Integrated Ltd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close