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

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


IBM Mainframe Forums -> ABENDS & Debugging
Post new topic   Reply to topic
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
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
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Fri Jul 27, 2007 6:17 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> ABENDS & Debugging

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top