Ted Holt
Ted Holt is the senior technical editor at The Four Hundred and editor of the former Four Hundred Guru newsletter at Guild Companies. Holt is Senior Software Developer with Profound Logic, a maker of application development tools for the IBM i platform, and contributes to the development of new and existing products with a team that includes fellow IBM i luminaries Scott Klement and Brian May. In addition to developing products, Holt supports Profound Logic with customer training and technical documentation.
-
Guru: Eliminate The Legitimate Use Of GOTO, Take Two
February 27, 2017 Ted Holt
I was annoyed that IBM chose not to support GOTO and TAG in free-form RPG calculations. I rarely used those opcodes, but when I did, it was in disciplined situations when nothing else would do. Besides, I didn’t want to be treated like a baby. Now it’s a non-issue. IBM finally provided an alternative to the last legitimate use of GOTO.
Almost five years ago, I wrote about a situation that I come across from time to time, namely the need to execute a clean-up routine before exiting an RPG subprocedure. Since nothing forbids a subprocedure to have multiple …
Read more -
Guru: SQL PL Labels
February 13, 2017 Ted Holt
SQL PL, the powerful, easy-to-learn procedural database language that IBM ships with all versions of DB2, allows you to identify any executable statement or compound statement with a label. I can’t think of a better day than today for us to think about why we might want to do that.
As a minimalist programmer, I avoid useless code, and that includes unnecessary labels. In the following paragraphs, I will list only the cases that require labels.
But first, a few ground rules.
- As with CL, a label name is followed by a colon when used to identify a statement.
-
Guru: SQL PL, WHILE And REPEAT Loops
January 18, 2017 Ted Holt
In earlier editions of this august publication, I covered the SQL PL looping structures that I consider to be the most useful. Today I cover the remaining looping structures. I cover them for completeness, but also because what I consider to be most useful may not be what you consider to be most useful.
To review, the FOR loop provides a simple way to process the rows of a result set. LOOP structure is versatile, providing the freedom to exit a loop from any point. The remaining loop structures are WHILE and REPEAT.
The WHILE loop is a top-tested loop. …
Read more -
RPG And The BLOB
December 13, 2016 Hey, Mike
… Read moreI’m trying to use a SELECT/INTO embedded SQL statement in an RPG program that accesses a table that includes a BLOB(20K) column. The INTO target is an externally defined data structure based on the table. However, I get compiler errors unless I remove the BLOB column from the table. What’s up with that?
—Four Hundred Guru reader
The problem is that RPG doesn’t have a native data type equivalent of a BLOB (or the other large object types CLOB/DBCLOB, for that matter.) The reason for this is that large object types can be up to 2GB in size, far
-
QTEMP Is A Different Animal
November 15, 2016 Hey, Ted
… Read moreI have a problem with an FTP script. I wish to send a file in QTEMP to a remote system, but the script tries to send the file from QGPL instead. The PUT command does not tell which library to send the file from because our standards prohibit the use of hard-coded library names. Any thoughts will be appreciated.
–Al
I commend you and other wise people in your shop for outlawing the hard-coding of library names, Al. The library list is a wonderful feature of IBM i, a feature that is sorely missing from other database systems. I have
-
Replacing Source in The Twenty-First Century
October 18, 2016 Ted Holt
… Read moreIn Searching Source in The Twenty-First Century, I introduced the use of regular expressions for searching within a source member. Searching is great, but sometimes you need to replace what the system finds with something else. Here’s how to replace text when using regular expressions.
Let’s begin with a source member.

Notice that there are nine constants named Stat10 through Stat90. Let’s replace Stat with Status_. Obviously we can’t replace Stat with Status everywhere it’s found. That would be disastrous!Instead, let’s use a regular expression to find the instances where Stat is followed by a digit.

I -
Searching Source In The Twenty-First Century
October 4, 2016 Ted Holt
… Read moreI love it when IBM gives me a way for me to do something I couldn’t do before. When I think of the tools I had to work with three decades ago, I could almost weep. Recently I had to search a source member for a string of characters, and I was overjoyed that LPEX gave me what SEU couldn’t.
To set the stage for my requirement, I should mention that as a matter of practice, I qualify data structures in my RPG programs. For me to omit the qualified keyword, I have to have a reason.
dcl-ds Status qualified;
-
Easy Printing from CL, Take Two
August 30, 2016 Hey, Ted
… Read moreWhen I read your statement that CL cannot write to printer files, I immediately thought, “It can’t? Then what have I been doing for the last couple of decades?” I looked through the article and saw that it didn’t mention my most used method, and I wondered how it was missed.
–Tom Liotta
Tom takes advantage of one of the best features of ILE, namely the ability to bind routines written in different languages to form one program. The non-CL procedure that he included is the printf function, which is well-known to C programmers. Even though printf produces stream
-
Message Data Data Structures
August 30, 2016 Hey, Ted
… Read moreSending Escape Messages from RPG is a great article. Your program defines the message data parameter as 80 bytes of character data, but the IBM Knowledge Center defines MSGDTA as char(*) with notes saying it can be up to 32,767 bytes. I would like a variable longer than 80 bytes, but instead of coding 100 today, 120 next project, and so on, how could I code it to take full advantage of the API?
–Glenn
You’re right that the API can handle up to 32K of data, but you need only define MsgDta as large as you need it to
-
How To Insert With A Common Table Expression
August 16, 2016 Hey, Ted
… Read moreI have to merge some new item numbers into our item master file. The problem I’ve run into is that there is more than one record for some items. None of the examples I found on the Web work for me. How do I write an SQL statement to copy all records from one file to another avoiding duplicates on part number?
–Trent
This is a new wrinkle on a challenge about which I have written before, namely the need to select only one row (record) to represent a group. (See the Related Stories below.) The wrinkle is that not
