Introduction

What is GixSQL?

GixSQL lets COBOL programs compiled with GnuCOBOL access relational databases through embedded SQL. A program contains SQL statements in EXEC SQL ... END-EXEC blocks:

           EXEC SQL
               SELECT COUNT(*) INTO :T1 FROM EMPTABLE
           END-EXEC.

These blocks are not COBOL: a precompiler translates them into calls to a runtime library, which sends the statements to the database and moves the data between the database and the COBOL fields.

Components

GixSQL consists of:

gixpp
the precompiler. It reads a COBOL source with embedded SQL and writes a pure COBOL source, where each EXEC SQL block is commented and replaced by calls to the runtime library (see The gixpp precompiler).
libgixsql
the runtime library, linked with the COBOL program. It manages the connections, cursors and host variables, and loads the database driver at run time.
libgixsql-<driver>
the database drivers, loaded dynamically by libgixsql according to the connection string (see Overview of the backends):
Driver Database Client library
pgsql PostgreSQL libpq
oracle Oracle Database ODPI-C (built in)
mysql MySQL, MariaDB libmariadb/libmysqlclient
odbc any database with an ODBC driver unixODBC
sqlite SQLite built in
SQLCA copybook
the SQL Communication Area, installed with the runtime (share/gixsql/copy), and included in programs with EXEC SQL INCLUDE SQLCA END-EXEC.

Development workflow

Development workflow
  1. Write the program with embedded SQL.
  2. Precompile it with gixpp.
  3. Compile and link the result with cobc, adding libgixsql.
  4. Run it, with the database driver libraries in the library path.

Precompiler concepts details each step with a complete example.

Relation with other precompilers

GixSQL started as a fork of Open-COBOL-ESQL (OCESQL), and was largely rewritten in C++. The SuperBOL edition adds compatibility with programs written for Oracle Pro*COBOL (see Migrating from Pro*COBOL).

Other open-source precompilers for GnuCOBOL are:

Feature summary

The features of GixSQL are compared with those of Pro*COBOL in Feature comparison, and the support of each backend is summarized in Overview of the backends.