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
 

 

What is SQLCODE -311 ? How to solve the error..

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> ABENDS & Debugging
View previous topic :: :: View next topic  
Author Message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Fri Jul 27, 2007 10:30 am    Post subject: What is SQLCODE -311 ? How to solve the error..
Reply with quote

Hai All,

I'm inserting the record into DB2 table thru application program. Now i'm getting Sqlcode -311. What is sqlcode -311? In my Cobol program i'm not declaring any host varibles. This problem occurs only in varchar of table varibles. I declare the table varible like these...

10 EMPADD.
49 EMPADD-LEN PIC S9(4) USAGE COMP.
49 EMPADD-TEXT PIC X(10).

Please Help me.....
Back to top
View user's profile Send private message

sandeep1dimri

New User


Joined: 30 Oct 2006
Posts: 76

PostPosted: Fri Jul 27, 2007 11:26 am    Post subject:
Reply with quote

error -311:==> When evaluated, the length specification for input host string variable, whose entry in the SQLDA is indicated by position-number, was negative or greater than the maximum.


10 EMPADD.
49 EMPADD-LEN PIC S9(4) USAGE COMP.
49 EMPADD-TEXT PIC X(10).
plse check that ur moving length of EMPADD-TEXT to EMPADD-LEN

Then insert EMPADD to the table.

Hope it will help.
sandeep
Back to top
View user's profile Send private message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Fri Jul 27, 2007 12:13 pm    Post subject:
Reply with quote

Hai

Still i'm getting the error. In my program i include <dclgen member>
And include <sqlca> and include <sqlda>.

10 EMPADD.
49 EMPADD-LEN PIC S9(4) USAGE COMP.
49 EMPADD-TEXT PIC X(10).

In my program i declare one dummy varible(Ename) to move the values to the table values. Now i accept the dummy varible(Ename) as 'Ranjan'.

Then
Move 6 to EMPADD-LEN.
move dummy varible(Ename) to table varible(empadd).

After that i'm insert the values...
But i'm getting the error sqlcode -311.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Fri Jul 27, 2007 2:29 pm    Post subject:
Reply with quote

Hi Rajesh,

Change your insert query like this.


Code:
INSERT INTO EMPLOYEE (EMP_I,
                                     EMP_ADDS )
                   VALUES
                                     (:WS-EMP-I
                                      ,:STRIP(:EMPADD.EMPADD-TEXT))


Thanks
Sai
Back to top
View user's profile Send private message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Fri Jul 27, 2007 3:59 pm    Post subject:
Reply with quote

Hai,

I tried it. But its not working... What is Strip?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jul 27, 2007 5:25 pm    Post subject:
Reply with quote

Instead of making us guess show us the code that you are using!
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: Fri Jul 27, 2007 6:17 pm    Post subject:
Reply with quote

Hello,

In addition to the INSERT also post the variables used by the insert.
Back to top
View user's profile Send private message
Rajesh S
Warnings : 1

New User


Joined: 11 Jul 2007
Posts: 54
Location: Chennai

PostPosted: Tue Jul 31, 2007 3:44 pm    Post subject:
Reply with quote

Hai All,

Its my DCLGEN, Here Two varibles are varchar.
******************************************************************
* DCLGEN TABLE(CORPORATE_TAB1) *
* LIBRARY(FSS31.DB2.DCL(CCD)) *
* ACTION(REPLACE) *
* LANGUAGE(COBOL) *
* QUOTE *
* LABEL(YES) *
* INDVAR(YES) *
* ... IS THE DCLGEN COMMAND THAT MADE THE FOLLOWING STATEMENTS *
******************************************************************
EXEC SQL DECLARE CORPORATE_TAB1 TABLE
( EMPNO VARCHAR(5) NOT NULL,
EMPNAME CHAR(10),
EMPADD VARCHAR(10),
EMPSAL INTEGER
) END-EXEC.
******************************************************************
* COBOL DECLARATION FOR TABLE CORPORATE_TAB1 *
******************************************************************
01 DCLCORPORATE-TAB1.
* *************************************************************
10 EMPNO.
49 EMPNO-LEN PIC S9(4) USAGE COMP.
49 EMPNO-TEXT PIC X(5).
* *************************************************************
10 EMPNAME PIC X(10).
* *************************************************************
10 EMPADD.
49 EMPADD-LEN PIC S9(4) USAGE COMP.
49 EMPADD-TEXT PIC X(10).
* *************************************************************
10 EMPSAL PIC S9(9) USAGE COMP.
******************************************************************
* INDICATOR VARIABLE STRUCTURE *
******************************************************************
01 ICORPORATE-TAB1.
10 INDSTRUC PIC S9(4) USAGE COMP OCCURS 4 TIMES.
******************************************************************
* THE NUMBER OF COLUMNS DESCRIBED BY THIS DECLARATION IS 4 *
******************************************************************

In my program. I'm not able to move the value to table varible(varchar). In this program i'm getting -311 sqlcode. How to solve this error?





IDENTIFICATION DIVISION.
PROGRAM-ID. FETCH3.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE CCD END-EXEC.
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL INCLUDE SQLDA END-EXEC.
77 ENO PIC X(5).
77 ENA1 PIC A(10).
77 EADD PIC X(10).
77 ESAL PIC 9(6).
77 SQLCODE1 PIC 9(5).
PROCEDURE DIVISION.
MPARA.
ACCEPT ENO.
ACCEPT ENA1.
ACCEPT EADD.
ACCEPT ESAL.
MOVE 4 TO EMPNO-LEN.
MOVE ENO TO WS1-EMPNO.
MOVE ENA1 TO WS2-EMPNAME.
MOVE 6 TO EMPADD-LEN.
MOVE EADD TO WS3-EMPADD.
MOVE ESAL TO WS4-EMPSAL.
EXEC SQL INSERT INTO CORPORATE_TAB1 VALUES
(:EMPNO,:WS2-EMPNAME,:EMPADD,:EMPSAL)END-EXEC.
IF SQLCODE = 00
DISPLAY "INSERT SUCCESSFUL"
ELSE
MOVE SQLCODE TO SQLCODE1.
DISPLAY "INSERT ERROR :", SQLCODE1.
STOP RUN.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Jul 31, 2007 5:32 pm    Post subject:
Reply with quote

You move values to EMPNO-LEN and EMPADD-LEN but you never move values to EMPNO-TEXT or EMPADD-TEXT. You never move a value to EMPSAL before you do the insert so most of what you are inserting is uninitialized garbage.
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 -> ABENDS & Debugging All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm
No new posts INVOKE WEBSERVICE error danik56 CICS 11 Thu Mar 09, 2017 11:52 am
No new posts Row not found Sql error GaganGarg DB2 7 Tue Mar 07, 2017 6:29 am
No new posts DB2 SQL Error: SQLCODE=-440, SQLSTATE... kishpra DB2 1 Sat Feb 18, 2017 2:31 am


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