Querying a Db2 database on a mainframe

Recently, I was in a situation where I had to query a Db2 database on a mainframe. I was also in a situation where the knowledge and documentation on that mainframe was not very widespread. So there I found myself, sitting in the dark with only a so-called 3270 screen looking at me, waiting for a first step that I would take.

The first question: how are the tables called. Second question: what tools to use to query the database.

I remembered from a distant past that IBM has a so-called “File-Aid” for Db2. This tool has a browse option that allows you to browse interactively tables in a Db2 database. The nice thing about it that the browse mode accepts wild-cards like *. When multiple answers are possible a pop-up appears that gives a clear choice on the possiblities. I used this tools to get a hunch of the table-names and to get a first impression on the content of the tables.

Once I had a list of filenames, I started with a second tool that gave me more insight. This tool is called “Spufi”. This tool basically uses two files (or datasets as they are called on a mainframe). One file is used to store the SQL statements, whereas a second dataset is used to capture the output. I realised that the two files must be allocated beforehand and that both files could best reside under your own name. I created two files: “tom.input.sql”  and “tom.output.txt”. I then used these two names in the first screen of Spufi where the exact names of input- and output files is being asked for.

This allowed me to start investigating the database.

 

Door tom