How to Connect Oracle 19c from Micro Focus Visual COBOL 8?
Installing Oracle 19c:
Download the Oracle Database 19c software from the Oracle website
Follow the installation guide provided by Oracle to install the software
Once the installation is complete, configure the Oracle listener and create a new database
Installing Micro Focus Visual COBOL 8:
Download the Micro Focus Visual COBOL 8 software from the Micro Focus website
Follow the installation guide provided by Micro Focus to install the software
Once the installation is complete, open the Micro Focus Visual COBOL 8 development environment
Creating an ODBC connection:
Open the ODBC Data Source Administrator by searching for it in the Windows Start menu.
Click on the "System DSN" tab and then click on the "Add" button
Select the "Oracle in OraClient19c_home1" driver and click on the "Finish" button
In the "Data Source Name" field, enter a name for the connection
In the "TNS Service Name" field, enter the service name of the Oracle 19c database
In the "User ID" field, enter the username for the Oracle 19c database
In the "Password" field, enter the password for the Oracle 19c database
Click on the "Test Connect" button to test the connection
If the connection is successful, click on the "OK" button to save the connection
Connecting to the Oracle 19c database from a COBOL program:
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.
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
Replace :db-name, :user-name, and :password with the appropriate values for the ODBC connection you created earlier
Once connected, you can use embedded SQL statements to interact with the Oracle 19c database
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.
Subscribe to my newsletter
Read articles from pratul gautam directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by