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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define a PIC 9(18) COMP field in a datable

Status
Not open for further replies.

cphill7292

Programmer
Oct 29, 2003
3
GB
If I define a field as PIC S9(18)COMP and try to include that in my embeded SQL I get the following error from the precompiler.

PCC-S-0026: Invalid host variable "CFP-F3"

My database is defined as:
Name Null? Type
-------- -------- ----------------------------
F1 VARCHAR2(1)
F2 VARCHAR2(8)
F3 NUMBER(18)

The record layout in my program is:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 CFP-REC.
03 CFP-F1 PIC X(01).
03 CFP-F2 PIC X(08).
03 CFP-F3 PIC S9(18) COMP.
EXEC SQL END DECLARE SECTION END-EXEC.

So the question is how do I define the column in the database to be able to store this field?

Cheers
 
I suppose you are using oracle precompiler.
In this case there no problem whith "-" character, but I always use COMP-3 data with numbers because using COMP, COMP-5, or DISPLAY data I often had strange problems.
So try and see ...

Erminio
 
Dimandja is partially correct.

With Oracle (and this is Oracle, precompiler Version 1 .. Old) the following variables NEED to be PIC S... e.g. signed, regardless of size of variable.

BINARY
COMP
COMP-3
COMP-5
PACKED-DECIMAL


But cphill7292 has shown a code that has indeed the S, so this is not the problem.


Replacing with COMP-3 may be the option, or if you are dealing with a Intel machine you can also use COMP-5.

With Oracle again you have the following.
NUMBER
or
NUMBER (p,s)

can be used with any of the following.
PIC S9...9 COMP

PIC S9(n) COMP

PIC S9...9 BINARY

PIC S9(n) BINARY

PIC S9...9 COMP-5

PIC S9(n) COMP-5

COMP-1

COMP-2

PIC S9...9V9...9 COMP-3

PIC S9(n)V9(n) COMP-3

PIC S9...9V9...9 DISPLAY

PIC S9(n)V9(n) DISPLAY

PIC [X...X| N...N| G...G]

PIC [X(n)| N(n)| G(n)]

PIC X...X VARYING

PIC X(n) VARYING



And you still haven't replied to my question.

Oracle version would be handy also.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Frederico,
You are correct, but if cphill7292 is in an intel machine, he or she need to use COMP-5 instead of COMP or better, use the precompiler directive comp5=yes.
From Pro*cobol 8.05 Precompiler Getting Started :

"To avoid potential inconsistencies when calling routines in the Oracle libraries, use the "COMP5YES" option. This step is required because binary numbers for COBOL BINARY/COMP data are stored in Big Endian format. Oracle libraries expect binary numbers to be stored in Little Endian format (machine format)."

With my precompiler I always use COMP-3 because too often I need numbers with decimal point, but for INDICATORS I always use COMP-5.

Regards,

Erminio
 
Thanks for all the suggestions, I managed to get this to work but only by moving to a 64 bit machine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top