Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting -301 while opening a cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Getting -301 while opening a cursor
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

Moderator


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

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

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

Site Director


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

PostPosted: Wed Jun 26, 2013 12:13 am    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Wed Jun 26, 2013 12:24 am    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Natural ADABAS Opening with CTS enikhilk Mainframe Jobs 0 Wed Nov 30, 2016 5:37 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
This topic is locked: you cannot edit posts or make replies. Job Opening for 3 to 10 yrs exp. in I... princeaggarwal Mainframe Jobs 0 Sat Aug 20, 2016 3:17 pm
No new posts PL/I: opening file w/ dynamically det... Sam Dodgers PL/I & Assembler 6 Wed Jul 27, 2016 4:05 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us