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 SQLblock 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
libgixsqlaccording to the connection string (see Overview of the backends):Driver Database Client library pgsqlPostgreSQL libpqoracleOracle Database ODPI-C (built in) mysqlMySQL, MariaDB libmariadb/libmysqlclientodbcany database with an ODBC driver unixODBC sqliteSQLite built in SQLCAcopybook-
the SQL Communication Area, installed with the runtime (
share/gixsql/copy), and included in programs withEXEC SQL INCLUDE SQLCA END-EXEC.
Development workflow
- Write the program with embedded SQL.
- Precompile it with
gixpp. - Compile and link the result with
cobc, addinglibgixsql. - 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:
- OCESQL: https://github.com/opensourcecobol/Open-COBOL-ESQL (PostgreSQL);
- esqlOC: https://github.com/OCamlPro/gnucobol-contrib/tree/master/esql (ODBC).
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.