How many times have you started to write a program in CL and become frustrated by CL's limited support for database I/O? Maybe you need to read one record by key or a relative record number from a file that contains millions of records. Perhaps you'd like to write a record to a log file or update a control file. Well, you can't. The only database I/O operation you can perform in CL is a sequential read. To do anything else, you must either scrap your CL code and start over in a language with better database support (e.g., RPG, Cobol) or call a program written in such a language.
You may even be forced to compromise. For example, you'd like to hold your program's setup information in a database file, but instead you have to use a data area. Or you'd like to log errors in the database, but you're forced to use a message queue -- all because of CL's limited support for database operations.
Fortunately, there are ways around these limitations. Back in the May 2000 issue of iSeries NEWS, Peter Clifford wrote an article entitled "CL Flexes Its Database Muscles" that provided a set of database I/O commands that let you OPEN, CLOSE, READ, UPDATE, WRITE, DELETE, and UNLOCK a record, as well as POSITION a file cursor in a database file, and retrieve and change a named field -- all from your CL programs.
You can read the article online at the following link:
http://www.iseriesnetwork.com/article.cfm?id=7217 [1]
You can download the code for this article from http://www.systeminetwork.com/code/clubtechcode/CLDBOperations.zip [2].
Links:
[1] http://www.iseriesnetwork.com/article.cfm?id=7217
[2] http://www.systeminetwork.com/code/clubtechcode/CLDBOperations.zip