COBSQL

You can use COBSQL to access the SQL functions offered by the Oracle Database Management Systems (DBMS) by embedding SQL statements within your COBOL program in the form:

EXEC SQL
   SQL statement
END-EXEC

and then using the Oracle precompiler to process the embedded SQL before passing the program to the COBOL Compiler. The database precompiler replaces embedded SQL statements with the appropriate calls to database services. Other additions are made to the source code to bind COBOL host variables to the SQL variable names known to the database system.

The advantage of embedding SQL in this way is that you do not need to know the format of individual database routine calls. The disadvantage is that the source code that you see when you debug your program is that output by the precompiler and not the original embedded SQL. You can overcome this disadvantage by using COBSQL.

COBSQL provides an integrated interface between Micro Focus COBOL and the third-party standalone precompiler, enabling you to debug a program containing EXEC SQL statements and display your original source code rather than the code produced by the precompiler.

Note:
  • You should only use COBSQL if you are already using it with an earlier version of a Micro Focus COBOL product and want to migrate your application to this system. For any other type of embedded SQL development, we recommend that you use OpenESQL.
  • You cannot use COBSQL with programs that have been compiled with the Compiler directive SOURCEFORMAT(VARIABLE) unless you are using Pro*COBOL. Pro*COBOL supports both SOURCEFORMAT(TERMINAL) and SOURCEFORMAT(VARIABLE). Otherwise, you must use OpenESQL if your programs are free format.
Important: This note applies to UNIX environments (remote development) only.

To access a DBMS from COBOL under UNIX, the COBOL run-time system needs to be aware of the API routines used by the DBMS. A database vendor might provide a script that creates either:

  • An executable run-time system, consisting of the COBOL run-time system and DBMS routines
  • A callable shared object of DBMS routines that can be located by the COBOL run-time system at run time

The script contains a cob command, and you can control the effect of the script by amending the options to the cob command. See cob (cob32 or cob64) Command for more information.