I recently wrapped up a couple of mainframe COBOL/DB2 classes at udemy.com. In general, these were refresher courses in COBOL, but I did find the EXEC SQL pre-processor very interesting.
I left the COBOL world before SQL was mainstream. When we used the computer database management system (DBMS), it was via calls like one would still do in most modern computer languages such as
CALL "DBGET" USING DBNAME, TABLENAME, ....
Once SQL came along some COBOLs (as far as I can recall HP’s COBOL/3000 was given this ability), there was a pre-processor (EXEC SQL) that allowed you to code SQL directly into COBOL such as
DISPLAY "ENTER USER-ID:". ACCEPT USER-ID. EXEC SQL SELECT USERNAME INTO :USER-NAME FROM USERTABLE WHERE USERID = :USER-ID END-EXEC. IF SQLCODE NOT = 0, DISPLAY "USER ID WAS NOT FOUND".
The mainframe COBOL/DB2 uses this pre-processor. Since there is no practical way for me to code on a mainframe (the service I looked into wanted over $300 / mo), I thought it would be neat to see if I could get a pre-processor running on gnuCOBOL. Turns out someone has written just such a pre-processor.
Getting the pre-processor running is a future topic, but one of the requirements is PostgreSQL – that is the DBMS it interfaces with.
So this blog post is my notes for getting PostgreSQL up and running.
PostgreSQL, mySQL, and SQLite
It has been years now since I used mySQL, but I did once heavily use it. I wrote an application that handled netflow data from a couple hundred routers. At the time I was pretty impressed that I was processing roughly 5 million records a day in mySQL. I liked mySQL but my knowledge of it is now 10 years out of date (jeez, how can that be??).
In my own projects for the past several years I selected SQLite as my DBMS software. I liked the licensing, and I was OK with the fact that cannot allow networked access. Plus it is very lightweight.
I believe I had looked at Postgres (as it was then called) when I looked at mySQL and mySQL looked like a much better solution then.
So how does PostgresSQL compare to mySQL and SQLite?
This article is a pretty quick comparison of the differences between the three:
A super high-level summary:
SQLite is good for IOT, or where an embedded database is necessary (my situation). It is not good for large volumes or networked access.
mySQL is popular, easy to use, and provides fast reads. Great for websites. Downside is Oracle hasn’t been keeping it current.
postgreSQL is better at data integrity and complex operations. Downside is a more complex product.
While researching PostgreSQL I found this tutorial site which I found very useful for quickly getting the DBMS installed, running, setting up some test tables, and experimenting with the DBMS:
Here are the highlights of installation:
- The installation procedure found in PostgreSQL Tutorial starts at
- Download the Installer.
Installers are found at
I’m installing onto a test Windows box. So I selected the latest and greatest PostgreSQL version.
- Run the Installer.
Answered a few questions and 10 minutes later PostgreSQL was installed. I looked at stack builder (end of installation), but there were no other optional packages I could see using at the moment.
- Once the PostgreSQL server is running, I started pgadmin4 (in start menu) to poke around. Although browser based, this is a very nice built in query tool.
Installing Test Data
The tutorial site includes test data of a fictional DVD rental store. It includes many tables, fields, and relationships to experiment with. Besides providing example data for their tutorial, it will provide me example data down the road for gnuCOBOL.
The instructions for downloading the DVD Rental Store database is found at
The procedure for uploading the data into the service is at
Once the data is loaded, I used pgadmin4 to verify the tables and data exist:
Following Along with the Tutorial
At this point, you have the necessary data installed to do the PostgreSQL tutorial. I did so just to get a feeling for this DBMS.
Compared to SQLite which I know well and my fading memory of mySQL of 10 years ago, this is an amazing product. It was easy to get running and use.
Installing a Different SQL Query Tool
pgadmin4 is much nicer than the tools that come with SQLite (and what I recall coming with mySQL long ago), but I’m not a big fan of web-based software. So I went looking for a different query tool.
I ended up settling on DBeaver. It is free, has lots of features, and also works with mySQL and SQLite so it could possibly become my de facto SQL tool. In my, so far, limited use of it, I like it though it has been really slow to start up.
You can find DBeaver here
Here is an example of output:
I now have a working DBMS to use with gnuCOBOL.