Created On:  10 April 2012

Problem:

I am using Visual COBOL for Eclipse R4 Update 2 under Windows and I am trying to create a project that contains COBOL programs that need to be precompiled using Oracle's Pro*COBOL precompiler.  Do you have an example of how to do this?

Resolution:

The following are the steps necessary to setup a Visual COBOL for Eclipse native COBOL project so that it can interact with the Oracle Pro*COBOL precompiler.

There are a few prerequisites to running with this sample.

1.  If you are using Oracle's Pro*COBOL then the appropriate Oracle client software including Pro*COBOL has to installed on your computer and must be accessible within the PATH.

2. You must be able to connect to the Oracle database using Oracles SQL Developer, etc. from your development computer.

3. The sample program assumes that the Oracle Sample database is installed and is accessible from the user account SCOTT/TIGER. Please change the username/password to one that is valid on your system, if necessary.

The following instructions are assuming that you have a program that needs to be compiled with Oracle's Pro*COBOL precompiler.

That means it uses the COBSQL preprocessor of Visual COBOL.

Open up the Visual COBOL Eclipse IDE and select File->New COBOL Project and then give the project a name like "oraconnect".

Click Finish.

Right click on the project name in Navigator and select New->COBOL Program

This should create a new program called Program1.cbl in the editor.

Copy and paste the following over the source for Program1.cbl in the editor:
You should replace the values of username and paswd with your own if these are not valid.

This also assumes that you have the Oracle Sample database installed.

IDENTIFICATION DIVISION.
PROGRAM-ID. ORACONNECT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME  PIC X(10).
01 PASSWD    PIC X(10).
01 EMP-NAME  pic x(50).
EXEC SQL END DECLARE SECTION END-EXEC.
PROCEDURE DIVISION.
LOGON.

   MOVE "SCOTT" TO USERNAME.
   MOVE "TIGER" TO PASSWD.
   EXEC SQL
      CONNECT :USERNAME IDENTIFIED BY :PASSWD
   END-EXEC.
   DISPLAY SQLCODE
   EXEC SQL SELECT EMP.ENAME INTO :EMP-NAME FROM EMP
      WHERE EMP.EMPNO = 7369
   END-EXEC
   DISPLAY EMP-NAME     *> this should = SMITH
   STOP RUN.

Save this.

Right click on the project name in Navigator again and select Properties.
Open Micro Focus COBOL-->Build Configurations-->COBOL

Target Type should be single executable file.
Platform should be 32-bit.

Click on the arrow next to Override COBOL Project settings

In the Additional Directives box copy and paste the following:

p(cobsql) CSQLT=ORACLE8 MAKESYN VERBOSE KEEPCBL END-C p(cp) ENDP ENDP litlink
Click Apply

Now click on the Link tab which is two below the COBOL tab in the properties list.

In the box for Additional items to be linked (obj, lib, etc)
enter in the location and name of the appropriate Oracle library,

On our test system for Oracle 11g client it looks like the following:

C:\app\username\product\11.2.0\client_1\precomp\LIB\orasql11.lib

It may have a different name depending on the version of Oracle you are using.

Click Apply and then OK to close the properties window.

If everything is setup correctly then it should compile and link cleanly.
If you get a compile or link error then check the steps above to ensure that the correct information has been entered.

If it compiles and links cleanly you should then be able to debug the program in the debug perspective.