Highlighted
Valued Contributor.
Valued Contributor.
232 views

Add, update and delete SQL records in COBOL

I am trying to create a program that links ACUCOBOL Runtime 10.3.0 with Microsoft SQL Server 2019 that allows user to:

1. Create a SQL table from COBOL

2. Add records to the table from COBOL

3. Update records in table from COBOL

4. Delete records in table from COBOL

 

Currently I am having troubles with the SQL part. I have tried the sample code here:

https://supportline.microfocus.com/documentation/books/sx40/spcesc.htm

 

Compiler shows that I am missing the EMPREC file. Where do I find this file?

If I manage to create a table, where is this table stored?

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Add, update and delete SQL records in COBOL

When you install Acu, did you select to have the AcuSQL precompiler and AcuSQL runtime installed? If you did, there are sample programs. Recent installs use C:\Users\Public\Documents\Micro Focus\extend 10.x.x\sample\acusql\mssql   Older installs would have the samples in C:\Program Files (x86)\Micro Focus\extend 9.x.x\AcuGT\sample\acusql. There is a create.sqb program and others sample program as well.

There is no EMPREC file. The documentation was stating that you can place your SQL statements in a copybook, like xxx (or any file name) and then include it in your COBOL code.

EXEC-SQL 
    INCLUDE xxx 
END-EXEC 

As far as where the table is stored, it will be in SQL Server defined by how you connect to the database ...

EXEC SQL CONNECT TO :dsn-name as C1
USER :userid USING :passwd
END-EXEC

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Add, update and delete SQL records in COBOL

Thanks, I found the sample programs but I still could not connect to server.

In SQL Management Studio, I created a local server TEST under RND\SQLEXPRESS (pic1) and tested connection successfully. When I tried to connect in create.sqb, it returned "data source name not found".

So, I followed the method here:

https://community.microfocus.com/t5/Silk-Test-Knowledge-Base/How-do-I-resolve-error-quot-IM002-Microsoft-ODBC-Driver-Manager/ta-p/1736235

and created a DSN (pic2). Connection test successful but the program still returned the same error.

What did I do wrong?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Add, update and delete SQL records in COBOL

Good morning.

Have you set this variable in your cblconfi?

ACUSQL_RUNTIME_DLL asqlsrvr.dll

Can you try and use just the server name "RND" for the connection?
You should not need to set any DSN in Windows.

Let us know. 

----------------------------
Claudio Contardi
Product Support Engineer, Senior
Micro Focus
0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Betreff: Add, update and delete SQL records in COBOL

here for example a complete application that read the german bank Information from ASCII and bring it in a SQL database, here with sqlite. This is a small and slow database, but the code will works on mssql an other databases.

connect, truncate, drop, insert, update, delete, create is demonstrated.

I hope that will help you!

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Add, update and delete SQL records in COBOL

Hi.

I added the variable in the cblconfi file as you suggested, but still not working.

I tried TEST, RND and RND\SQLEXPRESS, none of them could connect.

 

Side note:

How do I delete my messages in this forum? I only see the option to edit.

Also, why does it look like I replied to the wrong person?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Add, update and delete SQL records in COBOL

Good morning, @CHC 

Can you please return the value for wrun32.exe -v ?

Then, try to record a runtime trace file, so more information are available about what's possibly failing.

Add the following variables to your cblconfi:

FILE_TRACE 9
FILE_TRACE_FLUSH 1
FILE_TRACE_TIMESTAMP 1

 Then run again adding the following option:

wrun32.exe -le runtime.log -c .....

Regards.

----------------------------
Claudio Contardi
Product Support Engineer, Senior
Micro Focus
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.