IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting -301 while opening a cursor


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Tue Jun 25, 2013 11:57 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jun 26, 2013 12:06 am
Reply with quote

Can you post us sample of Sql
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 26, 2013 12:13 am
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Jun 26, 2013 12:24 am
Reply with quote

Was your "numeric" field USAGE DISPLAY or USAGE COMP-n?
Back to top
View user's profile Send private message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Wed Jun 26, 2013 12:26 am
Reply with quote

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
View user's profile Send private message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Wed Jun 26, 2013 1:03 am
Reply with quote

Akatsukami wrote:
Was your "numeric" field USAGE DISPLAY or USAGE COMP-n?


Hi Akatsukami,

It was USAGE DISPLAY.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 for z/OS and LUW Admin Job Opening Mainframe Jobs 0
No new posts Looking For a PDS Member Without Open... PL/I & Assembler 10
No new posts Vision PLUS Mainframe opening Mainframe Jobs 0
No new posts Urgent MF opening for TCS India Mainframe Jobs 0
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
Search our Forums:

Back to Top