SuperBOL - COBOL modernisation
#SuperQL#release#migration#SQL#Oracle#PostgreSQL

SuperQL: your Pro*COBOL and OpenESQL sources on GnuCOBOL

New in SuperBOL: SuperQL 1.0.0, an SQL precompiler and runtime for GnuCOBOL, for your Pro*COBOL and OpenESQL programs on Oracle, PostgreSQL or ODBC.

SuperQL: your Pro*COBOL and OpenESQL sources on GnuCOBOL

A new tool is available for COBOL applications with embedded SQL: SuperQL 1.0.0, an SQL precompiler and runtime for GnuCOBOL. It accepts sources written for Pro*COBOL as well as those written for OpenESQL (Micro Focus / Rocket Visual COBOL), and runs them on Oracle, PostgreSQL or through ODBC, with GnuCOBOL as the compiler.

If your applications currently run with procob on Oracle, or with Visual COBOL and OpenESQL, this article tells you what SuperQL takes from your programs as they are, what it reports, and how to try it on part of your code.

Why now

Compiler and production runtime licences weigh on every server, every acceptance testing environment, every container. The Oracle database adds its own. And the precompiler ties you to both: as long as your programs go through procob or through the Visual COBOL preprocessor, changing compiler or database means touching the embedded SQL of hundreds of programs.

What was missing to move such a codebase to GnuCOBOL was a precompiler able to take your sources without rewriting, and a runtime that reproduces the behaviour your programs expect: SQLCODE, SQLCA, transactions, cursors. That is the role of SuperQL.

SuperQL is the result of long development based on GixSQL, the GnuCOBOL community precompiler, whose community version continues at codeberg.org/GnuCOBOL/gixsql. Its runtime has been entirely rewritten in C.

Your Pro*COBOL sources

SuperQL reads Pro*COBOL syntax: DECLARE SECTION, VARYING variables (with a 2-byte length, like procob), indicators, host arrays with FOR :n and block FETCH, scrollable cursors, WHERE CURRENT OF, dynamic SQL (PREPARE, EXECUTE, EXECUTE IMMEDIATE), WHENEVER.

At run time, a single connection option, compat=oracle, applies the Pro*COBOL conventions:

  • explicit transactions, without autocommit;
  • cursors that remain open after COMMIT;
  • SQLCODE 1403 for "no row", and on PostgreSQL the Oracle codes for common errors;
  • a failing statement does not roll back the whole transaction, as on Oracle.

An extract from a test program, precompiled as is

           EXEC SQL CONNECT :USERNAME IDENTIFIED BY :PASSWD
                USING :DBNAME END-EXEC.
           EXEC SQL SELECT A, B, C, D INTO :R2, :R4, :R6, :R-D
                FROM SBLEN_T END-EXEC.

The same compiled program runs on Oracle or on PostgreSQL: only the connection string changes.

Your OpenESQL sources

SuperQL also accepts the OpenESQL forms found in the applications we have processed: CONNECT TO without USER, CLIENT CURSOR, INTO placed after FROM, and the Micro Focus conventions in the sources (COMP-X, $ directives including $SET SOURCEFORMAT, * comments in column 1, free format).

It is not a complete implementation of OpenESQL: if your programs use other forms, precompilation reports them, and we can add them.

Oracle or PostgreSQL: at your own pace

You can change compiler without changing database: SuperQL works with Oracle, through the usual Oracle client. The move to PostgreSQL can come later, or never.

When you decide to make it, precompilation rewrites the Oracle-specific SQL that PostgreSQL does not understand: SYSDATE, sequences, FROM DUAL, NVL, DECODE, (+) outer joins, some uses of ROWNUM, and the most common date and string functions. What cannot be rewritten without the risk of changing the meaning of the query is reported, to be handled by hand.

SQL errors at precompilation, not in acceptance testing

Like Pro*COBOL's sqlcheck=semantics, the --sqlcheck option has the database analyse each query, without executing it, at precompilation time: unknown objects, wrong number of host variables, variable too small, nullable value read without an indicator. By pointing --sqlcheck at the target database, you get, program by program, the list of what remains to be adapted: it is the inventory tool of a migration.

What changes in your build chain

Precompilation by procob or by Visual COBOL is replaced by SuperQL's, followed by cobc. The common Pro*COBOL options have their equivalent. The runtime, written in C, keeps binary compatibility with programs already compiled: an update does not require recompiling.

SuperQL is tested on PostgreSQL, Oracle, ODBC, MySQL and SQLite, with more than 900 automated test cases. It is part of the Build & Run family of our software, guaranteed open source.

How to try it

  1. A pilot set: a few representative programs, with their most specific SQL.
  2. Precompilation with --sqlcheck against the target database: the list of what passes as is, and of what must be adapted.
  3. Side-by-side execution: the same datasets on the old and the new toolchain.
  4. Roll-out in waves of applications.

SuperQL is available with the SuperBOL Subscription, which gives access to all our software and to support from the team that develops it. If you prefer to stay on the community version of GixSQL, our Pure open source support extends it for your programs and contributes these improvements upstream.

Do you have a Pro*COBOL or OpenESQL codebase? Send us a few programs, and we will tell you what passes as is.

Pro*COBOL and Oracle are trademarks of Oracle Corporation. Micro Focus and Visual COBOL are trademarks of Micro Focus / Rocket Software. Other names may be trademarks of their respective owners.

Read also

All news

Modernise your COBOL codebase with SuperBOL

From proof of concept to industrial-scale production deployment, get support from one of the main contributors to GnuCOBOL.

The SuperBOL logo

Download our logo in the version suited to your background.

Need another format? Contact us.