Hi everyone,
I'm working on a windows XP platform with a DB/2 database and I've got a problem when trying to insert (thru COBOL) a field that contains HIGH-VALUE.
Here is my problem illustrated with this little example :
My DB/2 table is created with :
and my cobol program (before precompilation with DB2 precompiler) is :
The error returned is -302 :THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE :
If I replace MOVE HIGH-VALUES TO HOST-LAST-NAME. by MOVE "Dupond" TO HOST-LAST-NAME. or MOVE HIGH-VALUE TO HOST-LAST-NAME(1:15).
the insertion goes well. So it seems that DB/2 interpret a COBOL PIC X(30) that contains HIGH-VALUES as a VARCHAR(60). Does someone knows why ? If it is possible to change that ? Does somebody got a explanation of that strage transformation at the DB/2 side ?
Thanks a lot in advance for your answers.
Best regards,
Yan302
I'm working on a windows XP platform with a DB/2 database and I've got a problem when trying to insert (thru COBOL) a field that contains HIGH-VALUE.
Here is my problem illustrated with this little example :
My DB/2 table is created with :
Code:
CREATE TABLE PERS (
RID INTEGER NOT NULL,
"LAST_NAME" VARCHAR(30),
"FIRST_NAME" VARCHAR(20),
"AGE" NUMERIC(3,0),
CONSTRAINT PERS_PK PRIMARY KEY (RID));
and my cobol program (before precompilation with DB2 precompiler) is :
Code:
IDENTIFICATION DIVISION.
PROGRAM-ID. INSER.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 WORK-VARS.
05 HOST-RID PIC S9(9) COMP-5.
05 HOST-LAST-NAME PIC X(30).
05 HOST-FIRST-NAME PIC X(20).
05 HOST-AGE PIC S9(4) COMP-5.
EXEC SQL END DECLARE SECTION END-EXEC.
EXEC SQL WHENEVER NOT FOUND CONTINUE END-EXEC.
EXEC SQL WHENEVER SQLERROR CONTINUE END-EXEC.
EXEC SQL WHENEVER SQLWARNING CONTINUE END-EXEC.
PROCEDURE DIVISION.
EXEC SQL
CONNECT TO sample user db2admin using ******
END-EXEC.
MOVE 1 TO HOST-RID.
MOVE HIGH-VALUES TO HOST-LAST-NAME.
MOVE "Jean" TO HOST-FIRST-NAME.
MOVE 33 TO HOST-AGE.
EXEC SQL
****************************************
INSERT INTO PERS
(
"RID", "LAST_NAME", "FIRST_NAME","AGE"
)
VALUES
(
:HOST-RID, :HOST-LAST-NAME, :HOST-FIRST-NAME, :HOST-AGE
)
END-EXEC.
IF NOT SQLCODE = 0 THEN
DISPLAY "ERROR : SQLCODE " SQLCODE UPON CONSOLE
ELSE
EXEC SQL COMMIT END-EXEC
END-IF.
STOP RUN.
The error returned is -302 :THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE :
If I replace MOVE HIGH-VALUES TO HOST-LAST-NAME. by MOVE "Dupond" TO HOST-LAST-NAME. or MOVE HIGH-VALUE TO HOST-LAST-NAME(1:15).
the insertion goes well. So it seems that DB/2 interpret a COBOL PIC X(30) that contains HIGH-VALUES as a VARCHAR(60). Does someone knows why ? If it is possible to change that ? Does somebody got a explanation of that strage transformation at the DB/2 side ?
Thanks a lot in advance for your answers.
Best regards,
Yan302