Super User Asked by Shooter on November 14, 2021
I am currently trying to run a cobol pgm with embedded sql that calls database in postgresql. I am running (GnuCOBOL) 2.2.0 on cygwin.
I have followed steps in https://github.com/opensourcecobol/Open-COBOL-ESQL. I manage to exec all steps. However, when i run the pgm i get OCESQL Connect not found as following :
$ ./INSERTTBL
* INSERTTBL STARTED *
libcob: module ‘OCESQLConnect’ not found
I suspect it’s libocesql.so not created in /usr/local/lib during ‘make install’
but I am not sure why it’s not created. Hence I can;t add into env >> export COB_PRE_LOAD=/usr/local/lib/libocesql.so . For ld library, i have added under export LD_LIBRARY_PATH=/usr/local/lib.
Thanks.
On Windows 10 OS:
Download esqlOC Component from http://www.kiska.net/opencobol/esql/
Using the option: ESQL Preprocessor and Runtime binaries for Windows x86-64 (AMD-64) andx86 (win32)
This link downloads the file BINARIES.ZIP
Unzip the BINARIES.ZIP file in the folder where theOpenCobolIDE4.7.6
EX: C:Program Files (x86)OpenCobolIDEGnuCOBOL
The binaries folder containing the esqlOC components is included
Figure #3 Compiler Preferences
Generate a new program cobol with extension .sqb (COBOL WITH EXEC SQL)
Include the connection to the Database.
a. Include the following working fields:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 HOSTVARS.
05 BUFFER PIC X(1024).
05 hVarD PIC S9(5)V99.
05 hVarC PIC X(50).
05 hVarN PIC 9 (12).
EXEC SQL END DECLARE SECTION END-EXEC.
b. Include in Procedure Division the following sentences:
*--------------------------------------------------------------------- *
CONNECT TO THE DATABASE
also possible with DSN: 'youruser / yourpasswd @ yourODBC_DSN'
----------------------------------------------------------------------
STRING 'DRIVER = {MySQL ODBC 5.1 Driver};'
'SERVER = localhost;'
'PORT = 3306;'
'DATABASE = database;'
'USER = mysql user;'
'PASSWORD = mysql password ;'
*------------------------------------------------- ---------------- *
'COMRESSED_PROTO = 0;'
INTO BUFFER.
EXEC SQLCONNECT TO: BUFFER
END-EXEC.
Compile the program that has .SQB extension. It will issue the following errors, but it is normal:
"C:Program Files (x86)OpenCobolIDEGnuCOBOLbin/ld.exe: cannot find -locsql.libcollect2.exe: error: ld returned 1 exit status"
Open the cobol program generated by the pre compiler with the .COB extension
Only compile the program with the .COB extension without modifying it.
Execute.
Answered by Eduardo A. Palmeyro on November 14, 2021
First of all: You need to download and install Open-COBOL-ESQL-1.2: Open-COBOL-ESQL-1.2.tar.gz
$ export CPPFLAGS="-I/opt/pgsql/include"
$ export LDFLAGS="-L/opt/pgsql/lib"
$ ./configure
$ make
$ sudo make install
Second: Export these Flags:
export COPY=/Users/francisco/Downloads/Open-COBOL-ESQL-1.2/copy
export SCR=/usr/local/share/gnucobol/copy
export OC_OBJ=/Users/francisco/Downloads/Open-COBOL-ESQL-1.2/dblib
Third: complile .cbl
ocesql random.cbl random.cob
Fourth: Make executable
cobc -x random.cob $OC_OBJ/ocdb.o $OC_OBJ/ocdblog.o $OC_OBJ/ocdbutil.o $OC_OBJ/ocesql.o $OC_OBJ/ocpgsql.o -I$COPY -I$SCR -locesql -lpq
Finally (crossing your fingers):
./random
Answered by Francisco Villavicencio on November 14, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP