Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Knowledge Partner
Knowledge Partner
505 views

Error in an Insert using BLOB with Acucobol and Embeded SQL

Hi,

We are trying to insert a file in a BLOB in the database. Is it possible to do it with Acucobol? Do someone have a sample for that?

The support team said that BLOB type is not supported but maybe someone found a way to deal with this restriction.

We have a variable defined in this way:

01 documento-BLOB SQL TYPE IS BLOB(1048576).

We can do a select but when we want to do an insert we receive a memory access violation error.

Regards,

Juan Manuel Urraburu
Director of Technology @ ProRM & Axtrio
Micro Focus Knowledge Partner
LinkedIn

0 Likes
5 Replies
Micro Focus Expert
Micro Focus Expert

Re: Error in an Insert using BLOB with Acucobol and Embeded SQL

I do not believe type is blob or usage blob is supported. You might try a large PIC X() field, say a size of 16K or something along those lines.

0 Likes
Knowledge Partner
Knowledge Partner

Re: Error in an Insert using BLOB with Acucobol and Embeded SQL

Hi, 

It didn´t work. Defining the variable this way:

01 documento-BLOB.
       49 MY-BLOB-LENGHT  PIC 9(9) BINARY.
       49 MY-BLOB-DATA        PIC X(16384).

Doesn´t compile and returns an error :

The host variable data lenght is out of range.
The host variable "DOCUMENTO-BLOB" is undefined.
A value is not compatible with the data type of its assignment tarjet. Target name is "DOCUMENTO". SQLSTATE=42821

Regards,

Juan Manuel Urraburu
Director of Technology @ ProRM & Axtrio
Micro Focus Knowledge Partner
LinkedIn

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: Error in an Insert using BLOB with Acucobol and Embeded SQL

Using the compiler - no options a PIC X(16384) compiles for me

Using the compiler and AcuSQL embedded precompiler .. the -Ps compiler option this compiles.

EXEC SQL INCLUDE SQLCA END-EXEC.

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 C-RECORD.
05 C-NUMBER PIC S9(3) COMP-5.
05 C-FIRST-NAME PIC X(20).
05 C-LAST-NAME PIC X(20).
05 C-BIRTHDAY PIC X(19).
05 C-INFO PIC X(16384).

01 dsn-name pic x(12).
01 userid pic x(8).
01 passwd.
49 passwd-length PIC s9(4) comp-5 value 0.
49 passwd-name PIC x(18).
EXEC SQL END DECLARE SECTION END-EXEC.

0 Likes
Knowledge Partner
Knowledge Partner

Re: Error in an Insert using BLOB with Acucobol and Embeded SQL

Hi,

AcuSQL is not being used but the DB2 precompiler. Then the generated Cobol source file is compiled with Acu this way:

db2 PREP ./Source/$1.sqb TARGET ANSI_COBOL BINDFILE FUNCPATH cob_generico COLLECTION cob_generico QUALIFIER cob_generico PACKAGE USING "$1"

db2 bind ./Bind/$1.bnd COLLECTION cob_generico QUALIFIER cob_generico

ccbl -Sp .:./Copylib:/desarrollo/cobol/llamados/FD:/desarrollo/cobol/auxiliares/definiciones_parametros:/desarrollo/cobol/auxiliares/definiciones_tablas:/desarrollo/cobol/auxiliares/definiciones_tablas/compras:/desarrollo/cobol/auxiliares/definiciones_tablas/roles:/desarrollo/cobol/auxiliares/definiciones_tablas/entidades:/desarrollo/cobol/auxiliares/definiciones_tablas/especialidades:/desarrollo/cobol/auxiliares/definiciones_tablas/historia:/home/db2inst1/sqllib/include/cobol_a -Ga -Zl -Zy -Za ./Source/$1.cbl

So, what compiler option do you propose?

Regards,

 

Juan Manuel Urraburu
Director of Technology @ ProRM & Axtrio
Micro Focus Knowledge Partner
LinkedIn

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: Error in an Insert using BLOB with Acucobol and Embeded SQL

Your compiler options look correct, there isn't anything special needed to compile. You might try -dw32

If the error is the 42821, that error is a DB2 error. The data item value is not recognized by DB2.  It would probably be best to provide the pre compiled output to Customer Care to see if they can sort it out.

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.