Customer Service 1-800-221-5528

DB2 for the COBOL Programmer, Part 1

by Curtis Garvin and Steve Eckols
15 chapters, 431 pages, 182 illustrations
Published 1999
ISBN 978-1-890774-02-8
List price: $45.00

This is the one DB2 book that focuses on what COBOL programmers…not DBAs…need to know. As a result, it works well for instructors who are training students for DB2 programming jobs in their region. And, yes, it will outperform any training materials that are available from IBM.

Although this edition of the book was published in 1999, trainers at mainframe shops tell us that DB2 programming is still being done the way it’s presented in this book. One reason for this is 70% or more of the programming in a mainframe shop is maintenance programming on “legacy” applications. Another reason is that IBM has always prided itself on the upward-compatibility of its software, so the code that worked in 1999 still works today.

Incidentally, this is the first mainframe book we developed with our “paired pages” format. It is also one of the last books that we published before we went to blue covers with Murach’s as part of the title. But if you’ve ever adopted any of our Murach’s books, you can count on this book to deliver the same level of practical, example-packed information…even though the cover is different!

"I just wanted to say that DB2 for the COBOL Programmer, Part 1 is one of the most helpful programming books I have ever bought. I was starting a new job, and although I had plenty of COBOL experience, I had no DB2 experience. With this book, I was ready-to-go in 2 days."

M. S., Contract Programmer, Ohio

  • About this Book
  • Table of Contents
  • Courseware
  • FAQs
  • Corrections

Book description

DB2 is the primary database management system (DBMS) for IBM mainframe computers that run under the z/OS operating system and its predecessors. Although you can use several different methods to work with DB2 databases, most DB2 work is done through COBOL programs. The goal of this book is to show how to develop and maintain those COBOL/DB2 programs.

Specifically, this book shows how to use Structured Query Language (SQL) within a COBOL program to retrieve and update data stored in DB2 databases. To get your students started right:

  • Chapters 1 and 2 show how to retrieve data from a single DB2 table.
  • Chapter 3 shows how to add rows to, delete rows from, and update rows in a single table.
  • Chapter 4 shows how to retrieve data from two or more related tables at the same time by using unions and joins.

When your students complete this section, they’ll be able to write production COBOL programs.

In section 2, each of the seven chapters expands upon the basic skills so your students can process DB2 data with more expertise. For instance,

  • Chapter 6 shows how to use the column functions to summarize or average the data in one column of a table.
  • Chapter 8 shows how to work with variable-length columns and nulls.
  • Chapter 11 shows how to maximize locking efficiency so your programs don’t tie up the system.

In this section, each chapter is written as an independent unit, so you can assign these chapters in whatever sequence you prefer.

In section 3, your students learn the skills for binding, precompiling, compiling, link editing, and testing COBOL programs:

  • Chapter 12 shows how to use DB2I, which is a development tool for preparing and running DB2 programs interactively.
  • Chapter 13 shows how to do these programming tasks in batch, without using DB2I.
  • Chapter 14 shows how to use SPUFI, a DB2I facility, for testing SQL statements and creating test tables.
  • Chapter 15 shows how to use the Query Management Facility (QMF) to add data to the test tables you create with SPUFI.

You can assign the chapters in this section any time after your students complete chapter 1.

Book features

  • This is the only DB2 book written for COBOL programmers. In contrast, most other DB2 books focus on database administration or ad hoc processing to the exclusion of many of the DB2 essentials for COBOL programming.
  • When your students complete section 1 of this book…just 142 pages…they’ll be developing COBOL programs that access, add, delete, or update the data in one or more DB2 tables. What’s more, they’ll understand how DB2 works.
  • This book presents 12 complete COBOL programs that work with DB2 databases. These programs show how the DB2 code is coordinated with the COBOL code.

What courses this book can be used for

If you offer mainframe programming courses in your curriculum, this book can be used for a complete course in DB2 programming. It can also be used as an information-only supplement to a COBOL programming course to show how DB2 is integrated with COBOL in a COBOL/DB2 program on a mainframe.

What software your students need

Since COBOL/DB2 applications run on IBM mainframes, this book is best used in curricula that provide free access to an IBM mainframe. Then, your students can compile and test their exercises and projects on that mainframe.

If your school doesn’t have access to an IBM mainframe, you can use this book to teach DB2 programming as an information-only course. Then, you won’t need a computer lab at all. This can work in conjunction with a COBOL course when you just want your students to know what’s different about DB2 programming and where it fits in the IT job market.

To view the table of contents for this book in a PDF, just click on the link below:

Table of Contents

If you aren’t already familiar with the supporting courseware that we provide for a book, please go to About our Courseware. As you will see, our courseware consists of the end-of-chapter activities in the book, the files in the student download at our retail site, and the instructor’s materials. These components provide everything that other publishers provide in a way that delivers better results.

If you are familiar with our courseware, here’s a quick summary of the courseware for this book. For a detailed description in PDF format, please read the Instructor’s Summary.

Student downloads from our site

  • The source code for the 12 programs that are presented in the book, along with the JCL, SQL, CLIST, and PROC code you need to compile and run the programs

Instructor’s materials

  • Behavioral objectives for each chapter
  • PowerPoint slides for classroom presentations
  • Short-answer tests and test answers
  • Student projects, test data, and project solutions


On this page, we’ll be posting answers to the questions that come up most often about this book. So if you have any questions that you haven’t found answered here at our site, please e-mail us. Thanks!

DB2 for the COBOL Programmer, Part 1 (2nd Ed.) is currently in its second printing. Since that printing, errors were discovered in the programs in chapters 2 and 3. Those errors are described below.

How to tell which printing your book is in

Below the copyright notation on the back of the title page (page ii), you'll find a series of numbers like this:

10 9 8 7 6 5 4 3 2

The number on the right of this sequence tells which printing your book is. In this example, it's in the second printing.

Corrections to the first and second printings

Corrections to Chapter 2

Pages 66-69

If an SQLCODE other than 0 or 100 is encountered when a row is fetched in module 170 of the sales inquiry program, the current code in that module does not end the PERFORM 160 loop in module 140 that gets invoice information UNTIL END-OF-INVOICES. You can correct this problem using one of two techniques. First, you can add another condition to the PERFORM 160 statement so it looks like this:


You can also correct this problem by modifying the error checking code in module 170 like this:

    IF SQLCODE NOT = 100

If you make this change, you can also remove the IF VALID-CURSOR statement from module 160, since the END-OF-INVOICES condition in that module will always be true if the cursor is not valid.

Correction to Chapter 3

Page 99

In module 000 of the enhanced update program, the SQLCODE is displayed if an error occurs during the processing of a transaction and the unit of work must be rolled back. The intent was to display the SQLCODE from the SQL statement that caused the error. But because the ROLLBACK statement in module 200 is executed before the SQLCODE is displayed, the SQLCODE from the ROLLBACK statement is displayed instead. The easiest way to correct this problem is to move the statement that displays the SQLCODE in module 000 before the PERFORM statement for module 200.

If you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

Murach college books and courseware since 1974