Difference between revisions of "Cobol and PostgreSQL"
(→Cobol) |
(→Sample Program) |
||
| (19 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | This chapter contains the description of a complete working example of a '''Cobol''' '''PostgreSQL''' program, the setup, source code and a simple compilation workflow are below. |
|
| + | * Program name: pgcobol |
||
| + | * Source code: pgcobol.cbl |
||
| + | * Intermediate preprocessed source code file: pgcobol.cbsql |
||
| + | * Cobol compiler output: pgcobol.out |
||
| + | * Database: Employee, with table emptable |
||
| + | * pgcobol print output file: pgcobol.prt |
||
| + | GixSQL is a way in which Cobol programs are able to use modern database management systems in a Linux environment. |
||
== Cobol == |
== 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 transactions world wide.<br /><br /> |
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 transactions world wide.<br /><br /> |
||
| − | 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. This very fact is of high value to enterprises, their investments are safe and well protected on the long term.<br /> |
+ | 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. This very fact is of high value to enterprises, their investments are safe and well protected on the long term.<br /><br /> |
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 [https://gnucobol.sourceforge.io/ GNUCobol]. |
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 [https://gnucobol.sourceforge.io/ GNUCobol]. |
||
=== GNUCobol === |
=== GNUCobol === |
||
| Line 11: | Line 18: | ||
= Practical introduction to GixSQL = |
= Practical introduction to GixSQL = |
||
| − | This chapter |
+ | This chapter provides guidance to set up a working GixSQL for GNUCobol with PostgreSQL development environment. |
== Prerequisites == |
== Prerequisites == |
||
* Debian 12 |
* Debian 12 |
||
* GnuCobol4 |
* GnuCobol4 |
||
* libmariadb-dev libmariadb-dev-compat libpq5 unixodbc libfmt9 |
* libmariadb-dev libmariadb-dev-compat libpq5 unixodbc libfmt9 |
||
| − | * GixSQL |
+ | * GixSQL, find the link below |
* optionally the PostgreSQL database server on the same machine. |
* optionally the PostgreSQL database server on the same machine. |
||
You obtain GixSQL here; [https://github.com/mridoni/gixsql/releases/download/v1.0.21dev/gixsql-debian-12-x64-1.0.21dev-1.deb GixSQL]. |
You obtain GixSQL here; [https://github.com/mridoni/gixsql/releases/download/v1.0.21dev/gixsql-debian-12-x64-1.0.21dev-1.deb GixSQL]. |
||
| − | Just install the software in the sequence above and the system is ready to go. |
+ | Just install the software in the sequence as described above and the system is ready to go. |
== Workflow == |
== Workflow == |
||
| Line 29: | Line 36: | ||
# Inspect the compilation listing |
# Inspect the compilation listing |
||
# Run the program |
# Run the program |
||
| + | == 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'. People that like to get their hands dirty follow the two steps below. |
||
=== gixsql precompilation === |
=== gixsql precompilation === |
||
The command invoking the precompile process is as follows:<br/> |
The command invoking the precompile process is as follows:<br/> |
||
<pre> |
<pre> |
||
| − | /usr/bin/gixsql |
+ | /usr/bin/gixsql pgcobol.cbl pgcobol.cbsql -S -I . -e ".,*.cpy,*.CPY" |
</pre> |
</pre> |
||
| − | The input file is |
+ | The input file is pgcobol.cbl, the preprocessing output file is [[pgcobol.cbsql]]. It is very important to leave the cbsql file as is, because meddling with the file easily leads to errors in the next step of the workflow. |
=== The cobc GNUCobol compilation === |
=== The cobc GNUCobol compilation === |
||
The command invoking the precompile process is as follows: |
The command invoking the precompile process is as follows: |
||
<pre> |
<pre> |
||
| − | /usr/bin/cobc -x |
+ | /usr/bin/cobc -x pgcobol.cbsql -l:libgixsql.so -T pgcobol.out |
</pre> |
</pre> |
||
| − | This results in the executable program file ''' |
+ | This results in the executable program file '''pgcobol''' and the compilation listing [[pgcobol.out]]. |
== Sample Program == |
== Sample Program == |
||
| − | The sample program makes use of the sample database: [[ |
+ | The sample program [[pgcobol.cbl]] makes use of the sample database: employee. When executed pgcobol puts out the file [[pgcobol.prt]]. |
== Sample 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. |
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'. |
||
<hr/> |
<hr/> |
||
Back to: [[voorpagina]] |
Back to: [[voorpagina]] |
||
Latest revision as of 16:15, 7 November 2025
This chapter contains the description of a complete working example of a Cobol PostgreSQL program, the setup, source code and a simple compilation workflow are below.
- Program name: pgcobol
- Source code: pgcobol.cbl
- Intermediate preprocessed source code file: pgcobol.cbsql
- Cobol compiler output: pgcobol.out
- Database: Employee, with table emptable
- pgcobol print output file: pgcobol.prt
GixSQL is a way in which Cobol programs are able to use modern database management systems in a Linux environment.
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 transactions world wide.
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. This very fact is of high value to enterprises, their investments are safe and well protected on the long term.
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 GNUCobol as OpenCobol. GNUCobol now is a full blown Cobol compiler.
GixSQL links 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 GixSQL
This chapter provides guidance to set up a working GixSQL for GNUCobol with PostgreSQL development environment.
Prerequisites
- Debian 12
- GnuCobol4
- libmariadb-dev libmariadb-dev-compat libpq5 unixodbc libfmt9
- GixSQL, find the link below
- optionally the PostgreSQL database server on the same machine.
You obtain GixSQL here; GixSQL. Just install the software in the sequence as described 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
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'. People that like to get their hands dirty follow the two steps below.
gixsql precompilation
The command invoking the precompile process is as follows:
/usr/bin/gixsql pgcobol.cbl pgcobol.cbsql -S -I . -e ".,*.cpy,*.CPY"
The input file is pgcobol.cbl, the preprocessing output file is pgcobol.cbsql. It is very important to leave the cbsql file as is, because meddling with the file easily leads to errors in the next step of the workflow.
The cobc GNUCobol compilation
The command invoking the precompile process is as follows:
/usr/bin/cobc -x pgcobol.cbsql -l:libgixsql.so -T pgcobol.out
This results in the executable program file pgcobol and the compilation listing pgcobol.out.
Sample Program
The sample program pgcobol.cbl makes use of the sample database: employee. When executed pgcobol puts out the file pgcobol.prt.
Sample database
The employee database is a very simple database, with one table containing three lines. The pg_dump file is in the link.
Back to: voorpagina