How to Connect Oracle 19c from Micro Focus Visual COBOL 8?

pratul gautampratul gautam
2 min read

Installing Oracle 19c:

  1. Download the Oracle Database 19c software from the Oracle website

  2. Follow the installation guide provided by Oracle to install the software

  3. Once the installation is complete, configure the Oracle listener and create a new database

Installing Micro Focus Visual COBOL 8:

  1. Download the Micro Focus Visual COBOL 8 software from the Micro Focus website

  2. Follow the installation guide provided by Micro Focus to install the software

  3. Once the installation is complete, open the Micro Focus Visual COBOL 8 development environment

Creating an ODBC connection:

  1. Open the ODBC Data Source Administrator by searching for it in the Windows Start menu.

  2. Click on the "System DSN" tab and then click on the "Add" button

  3. Select the "Oracle in OraClient19c_home1" driver and click on the "Finish" button

  4. In the "Data Source Name" field, enter a name for the connection

  5. In the "TNS Service Name" field, enter the service name of the Oracle 19c database

  6. In the "User ID" field, enter the username for the Oracle 19c database

  7. In the "Password" field, enter the password for the Oracle 19c database

  8. Click on the "Test Connect" button to test the connection

  9. If the connection is successful, click on the "OK" button to save the connection

Connecting to the Oracle 19c database from a COBOL program:

  1. In Micro Focus Visual COBOL 8, create a new project and add the embedded SQL preprocessor to the project by going to Project -> Properties -> Preprocessors and selecting the embedded SQL preprocessor.

  2. In your COBOL code, use the following code to connect to the Oracle 19c database using the ODBC connection:

    EXEC SQL CONNECT TO :db-name USER :user-name IDENTIFIED BY :password END-EXEC

  3. Replace :db-name, :user-name, and :password with the appropriate values for the ODBC connection you created earlier

  4. Once connected, you can use embedded SQL statements to interact with the Oracle 19c database

  5. Once you are done with the connection and working with data, make sure to close the connection by using

    EXEC SQL DISCONNECT :db-name END-EXEC


By following these steps, you should be able to connect to an Oracle 19c database from a Visual COBOL program using embedded SQL and an ODBC connection.

0
Subscribe to my newsletter

Read articles from pratul gautam directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

pratul gautam
pratul gautam