GixSQL
GixSQL is a way in which Cobol programs are able to use modern database management systems in a Linux environment. A setup with a Cobol PostgreSQL program and a simple compilation workflow are below.
Contents
Cobol
Cobol has been around for more than 60 years and will stay around for the foreseeable future, estimates are that there are about 800 billion lines of Business Cobol code around. The programs are heavily used, servicing about 80% of all financial and business transaction.
The reason behind this endurance lies in the fact that Cobol is a standardised language, a program written in 1974 can be compiled today with a modern compiler. The resulting executable program still runs today, without the need of adaptation.
Traditionally Cobol programs have their application in big business mainframe environments. These large enterprises, however, are shifting more and more of their applications to the Linux platform. The broad adoption of Linux in the enterprise environment started around 2010. So, it is no wonder that Cobol gradually is being made available for the Linux platform, enter GNUCobol.
GNUCobol
Is an Open Source Cobol compiler, the project originally started in 2002 [ https://en.wikipedia.org/wiki/GnuCOBOL GNUCobol ] as OpenCobol. GNUCobol is now a full blown Cobol compiler.
PostgreSQL and Cobol
PostgreSQL is getting more and more traction around the world, also in the big enterprises. Big enterprises have ample reason to stick to their Cobol program stack, in which they invested huge amounts of money. So if PostgreSQL is to make it to the business applications of the big enterprises, it has to find a way to interact in a reliable manner with Cobol. Enter the GixSQL SQL preprocessor for Cobol.
Practical introduction to GiSQL
This chapter contains guidance to set up a working GixSQL for PostgreSQL development environment.
Prerequisites
- Debian 12
- GnuCobol4
- libmariadb-dev libmariadb-dev-compat libpq5 unixodbc libfmt9
- GixSQL
- optionally the PostgreSQL database server on the same machine.
You obtain GixSQL here; GixSQL. Just install the software in the sequence above and the system is ready to go.
Workflow
Once the editing of the program is finished, the program has to be compiled. This is done in various steps, but this can also be done by using the Python script below.
The steps are:
- The precompile process
- Inspect (but do not edit the output)
- The compilation process
- Inspect the compilation listing
- Run the program
gixsql precompilation
The command invoking the precompile process is as follows:
/usr/bin/gixsql cobolpostgresql.cbl cobolpostgresql.cbsql -S -I. -e ".,*.cpy,*.CPY"
The input file is cobolpostgresql.cbl, the output file is cobolpostgresql.cbsql.
The cobc GNUCobol compilation
The command invoking the precompile process is as follows:
Sample Program
The sample program makes use of the sample database: employee database.
Sample database
The employee database is a very simple database, with one table containing three lines. The pg_dump file is in the link.
Simple Workflow script
The python script gixc.py implements the GixSQL Cobol compilation workflow. It is invoked with a single parameter, being the program_name suffixed by either 'cbl or 'cob'.
Back to: GixSQL