View previous topic :: View next topic
|
Author |
Message |
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
Hi,
We were getting -301 DB2 error code while opening a cursor.
In our program, we had moved a numeric field of 16 bytes to alphanumeric field of 30 bytes.
From the manual, I could see that
Code: |
SQL Code -301: “THE VALUE OF INPUT HOST VARIABLE NUMBER position-number CANNOT BE USED AS SPECIFIED BECAUSE OF ITS DATA TYPE”
Explanation: A variable, expression, or parameter in position number could not be used as specified in the statement because its data type is incompatible with the intended use of its value.
This error can occur as a result of specifying an incorrect host variable or an incorrect SQLTYPE value in a SQLDA on an EXECUTE or OPEN statement. In the case of a user-defined structured type, the associated built-in type of the host variable or SQLTYPE might not be compatible with the parameter of the TO SQL transform function defined in the transform group for the statement. In the case of performing an implicit or explicit cast between character and graphic data types, this error indicates that such a cast was attempted with a non-Unicode character or graphic string
The statement cannot be processed.
|
When we executed the program again, we did not get the error.
What could have been the reason for getting -301 1st time? |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Can you post us sample of Sql |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How did you ensure that the value in the host variable was correct both runs?
I suspect there is a problem in the code that overwrote something. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Was your "numeric" field USAGE DISPLAY or USAGE COMP-n? |
|
Back to top |
|
|
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
dick scherrer wrote: |
Hello,
How did you ensure that the value in the host variable was correct both runs?
I suspect there is a problem in the code that overwrote something. |
Hi Dick,
We did not change anything in the Input and just executed again.
Pls see the contents of the code below.
************ COPYBOOK ******************
Code: |
01 GRP-REC.
05 IN-RECS.
10 NUM-ID PIC 9(16).
|
************ DCLGEN ******************
Code: |
01 DCLTAB1.
10 COL-ID PIC X(30).
|
************ CURSOR ******************
Code: |
DECLARE CSR1 CURSOR FOR
SELECT ID
FROM TAB1
WHERE COL_ID = :DCLTAB1.COL-ID
WITH UR
END-EXEC.
|
*** MOVE STATEMENT BEFORE OPENING CURSOR ***
Code: |
MOVE NUM-ID OF GRP-REC
TO COL-ID
OF DCLTAB1.
|
|
|
Back to top |
|
|
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
Akatsukami wrote: |
Was your "numeric" field USAGE DISPLAY or USAGE COMP-n? |
Hi Akatsukami,
It was USAGE DISPLAY. |
|
Back to top |
|
|
|