Writing BLOB column from Cobol
910469Jan 11 2012 — edited Jan 12 2012Hi,
I´m using the Pro*Cobol pre-compile to execute SQL statements into programs Cobol Net Express.
I need two helps.
1 - How can do to the Pro*Cobol cut the blanks on the right into PIC X Varying hosts variables ?
For example :
..... LastName VARCHAR(20)
..... 05 LASTNAME PIC X(20) VARYING.
The Pro*Cobol documentation say that precompile transform the elementary item LASTNAME to the group item bellow :
05 LASTNAME.
10 LASTNAME-LEN PIC S9(04) COMP.
10 LASTNAME-ARR PIC X(20).
When a string less than 20 is moved to LASTNAME-ARR, the exact string lenght is moved to the LASTNAME-LEN and the string is writen
into DB without blanks on right.
When a string is red from DB, the precompile write into LASTNAME-LEN the exact string lenght and the LASTNAME-ARR receive the
string value without blanks on write.
Occurs that when I compile the program the Pro*Cobol/Micro Focus don´t recognize LASTNAME-LEN and LASTNAME-ARR.
Am I correct ? May I use any directive that resolve that ?
2 - I need to check these step-by-step to write a text file generated from cobol into a BLOB column.
The LOAD FROM FILE statement receive SQLCODE -22275 : Invalid LOB locator specified.
Assumptions :
MAG-RELAT-BFILE SQL-BFILE.
MAG-RELAT-BLOB SQL-BLOB.
The fiel R1401 exists in D:\Petros\NE\
Source Code :
MOVE 'D:\Petros\NE\' TO ALIAS
MOVE 13 TO ALIAS-L
MOVE 5 TO FILENAME-L
MOVE 'R1401' TO FILENAME
EXEC SQL
ALLOCATE :IMAG-RELAT-BFILE
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB FILE SET :IMAG-RELAT-BFILE
DIRECTORY = :ALIAS,
FILENAME = :FILENAME
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOB FILE SET' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
ALLOCATE :IMAG-RELAT-BLOB
END-EXEC
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB LOAD :TOTAL-BYTES
FROM FILE :IMAG-RELAT-BFILE
INTO :IMAG-RELAT-BLOB
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOAD FFOM FILE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE, IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
Thanks,