Highlighted
Honored Contributor.
Honored Contributor.
697 views

String data - right truncation[32]

hi

I' have program that run with cobol server 4.0,

compiled with Enterpsie developer 4.0 for eclipse,

on windows 2012 and give this error:

SQLCODE: +00000001                                    

SQLSTATE: 01004                                       

SQL MESSAGE TEXT: String data - right truncation[32]  

EXPANDED TEXT: String data - right truncation[32]     

 

in odbc trace i have found thos print:

) d88-1b74 EXIT SQLDriverConnectW with return code 1 (SQL_SUCCESS_WITH_INFO)
HDBC 0x0077E868
HWND 0x00010010
WCHAR * 0x74421F7C [ -3] "******\ 0"
SWORD -3
WCHAR * 0x74421F7C <Invalid buffer length!> [-3]
SWORD -3
SWORD * 0x00000000
UWORD 0 <SQL_DRIVER_NOPROMPT>

DIAG [01004] [Oracle][ODBC]String data, right truncated. (0) 

 

What can I look for?

 

thanks bye

0 Likes
4 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: String data - right truncation[32]

sqlcode=1 Comes when a variable have a false length. Please verify all database fields and the Cobol fields.
Can you Show us the sqlcommand, the create Statement and the Cobol varialbe?
thanks
0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: String data - right truncation[32]

if you read the message error, the buffer length will be given, also string data, right truncated
0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: String data - right truncation[32]

the descr of oracle table,

cursor declare,

fetch cursor and

cobol area below:

 

NOTE:

- I have only a varchar2 column INTESTAZIONE

- with cobol server in 2.3.2 version it's work fine:

 

05 HV-TABLE-INTESTAZIONE.
     49 HV-TABLE-INTESTAZIONE-L PIC S9(0004) COMP.
     49 HV-TABLE-INTESTAZIONE-T PIC X(0160).

 

descr TABLE
Nome Nullo Tipo
------------------ -------- ------------------
ID NOT NULL NUMBER(15)
COD_ISTITUTO NOT NULL NUMBER(5)
CODICE_ABI NOT NULL NUMBER(6)
NDG NOT NULL CHAR(16 CHAR)
INTESTAZIONE NOT NULL VARCHAR2(160 CHAR)
DATA_CONTABILE NOT NULL NUMBER(8)
FENOMENO NOT NULL NUMBER(9)
TIPO_FIN NOT NULL NUMBER(3)
UFFICIO NOT NULL CHAR(7 CHAR)
OPERATORE NOT NULL CHAR(13 CHAR)
DATA_RICHIESTA NOT NULL NUMBER(8)
TIPO_RICHIESTA NOT NULL CHAR(4 CHAR)
CONFERMA NOT NULL CHAR(1 CHAR)
STATO_RICHIESTA NOT NULL CHAR(2 CHAR)
DATA_INS NOT NULL NUMBER(8)
ORA_INS NOT NULL NUMBER(8)
DATA_VAR NOT NULL NUMBER(8)
ORA_VAR NOT NULL NUMBER(8)
OPERATORE_VAR NOT NULL CHAR(13 CHAR)
NUMERO_MESSAGGIO NOT NULL NUMBER(7)
DATA_PRO_MESSAGGIO NOT NULL NUMBER(8)
VERSION NOT NULL NUMBER(16)

EXEC SQL
DECLARE TABLE_17 CURSOR WITH HOLD FOR
SELECT ID ,
COD_ISTITUTO ,
CODICE_ABI ,
NDG ,
INTESTAZIONE ,
DATA_CONTABILE ,
FENOMENO ,
TIPO_FIN ,
UFFICIO ,
OPERATORE ,
DATA_RICHIESTA ,
TIPO_RICHIESTA ,
CONFERMA ,
STATO_RICHIESTA ,
DATA_INS ,
ORA_INS ,
DATA_VAR ,
ORA_VAR ,
OPERATORE_VAR ,
NUMERO_MESSAGGIO ,
DATA_PRO_MESSAGGIO,
VERSION
FROM TABLE
WHERE COD_ISTITUTO = :HV-TABLE-COD-ISTITUTO
AND TIPO_RICHIESTA = :HV-TABLE-TIPO-RICHIESTA
AND STATO_RICHIESTA IN ('40', '50')
END-EXEC.

EXEC SQL
FETCH TABLE_17
INTO :HV-TABLE-ID ,
:HV-TABLE-COD-ISTITUTO ,
:HV-TABLE-CODICE-ABI ,
:HV-TABLE-NDG ,
:HV-TABLE-INTESTAZIONE ,
:HV-TABLE-DATA-CONTABILE ,
:HV-TABLE-FENOMENO ,
:HV-TABLE-TIPO-FIN ,
:HV-TABLE-UFFICIO ,
:HV-TABLE-OPERATORE ,
:HV-TABLE-DATA-RICHIESTA ,
:HV-TABLE-TIPO-RICHIESTA ,
:HV-TABLE-CONFERMA ,
:HV-TABLE-STATO-RICHIESTA ,
:HV-TABLE-DATA-INS ,
:HV-TABLE-ORA-INS ,
:HV-TABLE-DATA-VAR ,
:HV-TABLE-ORA-VAR ,
:HV-TABLE-OPERATORE-VAR ,
:HV-TABLE-NUMERO-MESSAGGIO ,
:HV-TABLE-DATA-PRO-MESSAGGIO,
:HV-TABLE-VERSION
END-EXEC.


01 HV-TABLE.
05 HV-TABLE-ID PIC S9(0015) COMP-3.
05 HV-TABLE-COD-ISTITUTO PIC S9(0005) COMP-3.
05 HV-TABLE-CODICE-ABI PIC S9(0006) COMP-3.
05 HV-TABLE-NDG PIC X(0016).
05 HV-TABLE-INTESTAZIONE.
49 HV-TABLE-INTESTAZIONE-L PIC S9(0004) COMP.
49 HV-TABLE-INTESTAZIONE-T PIC X(0160).
05 HV-TABLE-DATA-CONTABILE PIC S9(0008) COMP-3.
05 HV-TABLE-FENOMENO PIC S9(0009) COMP-3.
05 HV-TABLE-TIPO-FIN PIC S9(0003) COMP-3.
05 HV-TABLE-UFFICIO PIC X(0007).
05 HV-TABLE-OPERATORE PIC X(0013).
05 HV-TABLE-DATA-RICHIESTA PIC S9(0008) COMP-3.
05 HV-TABLE-TIPO-RICHIESTA PIC X(0004).
05 HV-TABLE-CONFERMA PIC X(0001).
05 HV-TABLE-STATO-RICHIESTA PIC X(0002).
05 HV-TABLE-DATA-INS PIC S9(0008) COMP-3.
05 HV-TABLE-ORA-INS PIC S9(0008) COMP-3.
05 HV-TABLE-DATA-VAR PIC S9(0008) COMP-3.
05 HV-TABLE-ORA-VAR PIC S9(0008) COMP-3.
05 HV-TABLE-OPERATORE-VAR PIC X(0013).
05 HV-TABLE-NUMERO-MESSAGGIO PIC S9(0007) COMP-3.
05 HV-TABLE-DATA-PRO-MESSAGGIO PIC S9(0008) COMP-3.
05 HV-TABLE-VERSION PIC S9(0016) COMP-3.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: String data - right truncation[32]

Hi, I use MySQL so may be different but... I get this error when I don't give columns a name which means the column name is automatically generated and may be too long and results in a string truncation error! i.e. nothing to do with the data returned! It had me pulling my hair out when I started using exec sql but I know now so always check for this!
e.g.
exec sql SELECT CASE WHEN xxxxxxxxxx = yyyyyyyyyy THEN zzzzzzzzzzz ELSE kkkkkkkkkkkkkk END INTO :my_result FROM myDB end-exec

TO FIX add 'AS' clause...
exec sql SELECT CASE WHEN xxxxxxxxxx = yyyyyyyyyy THEN zzzzzzzzzzz ELSE kkkkkkkkkkkkkk END AS myCol INTO :my_result  FROM myDB end-exec

There is probably a limit on the auto-generated column name of 256 chars so when my case statement is more than that I get the error!

Hope this helps.

Regards,
Linden

Linden Rowland - IT Consultant
Owner/Developer, www.SchoolReportWriter.com
IT Consultant to Tindle Newspaper Group

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.