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.
-
One Save File from More than One Library
March 26, 2008 Hey, Ted
I would like to place objects from several libraries in a save file. When I run a Save Library (SAVLIB) or Save Object (SAVOBJ) command that specifies more than one library, I receive message CPF3789: Only one library allowed with specified parameters. I really don’t want a bunch of save files. Is there another way?
–Jackie
A save file can contain other save files, so here’s a method you can try. To keep it simple, let’s say you want to save the contents of two libraries–MYLIB1 and MYLIB2–to one save file–SOMELIB/SOMESAVF.
1. Create a save file for each library.
CRTSAVF
-
Grouping a Union
March 19, 2008 Hey, Ted
We have several sales history files–one for each year. When I need to combine data for more than one year, I have to use an SQL UNION. I am trying to group “unioned” data and can’t seem to get it right. Is it possible to group a dataset that is built by a union?
–Tom
This appears to be an easy problem to resolve, but appearances can be deceiving. If you’re not careful, you can get the wrong results when you UNION two or more tables, especially when you’re summarizing data.
Divide the query into two steps: one to union
-
More About SQL Correlation Names
March 12, 2008 Hey, Ted
I hope my question is an easy one to answer. I have a file that stores the location of inventory in a warehouse. Location consists of a row (an aisle), column, and level. Why will an SQL UPDATE let me change the column and level, but not the row?
–Scott
You can update the column like this:
update qtemp/inventory set column=4 where item = 'SL-701'
But updating the row gives you error SQL0104. (Token 4 was not valid. Valid tokens: ( : DAY CAST CHAR DATE DAYS HOUOUR LEFT TIME TRIM YEAR COUNT MONTH.)
update qtemp/inventory set row=4 where item
-
Don’t Let SQL Name Your Baby, Take 2
March 5, 2008 Hey, Ted
Don’t Let SQL Name Your Baby gave some good advice on tackling the problems created by column names longer than 10 characters. Table names of more than 10 characters can also cause problems, especially if you need to add the same table on multiple systems. Plus, if you want to do updates in an RPG program, it’s nice to have a record format name different from the table name.
–Tim
Tim points out another discrepancy between the System i’s QSYS.LIB file system and relational databases that run on other systems. Using SQL, you can create a table with a very
-
LPEX Edit in Hex Mode
February 20, 2008 Hey, Ted
Thanks for your article, Let WDSc Help You Format Your Source Code. Prior to using WDSc, I used a tool to colorize my RPG source code. It applied different colors to various types of lines (comments, loop structures, etc.). LPEX doesn’t seem to be able to understand the hex code and displays box symbols for the hex value. Is there something in the parser controls that will make LPEX recognize the hex value or simply ignore it?
–Eddie
I don’t know if there’s anything in those parser controls that will make LPEX interpret those p-field codes or not, Eddie.
-
Don’t Let SQL Name Your Baby
February 6, 2008 Hey, Ted
We have started using SQL Data Definition Language (DDL) to define our physical files. One feature we really like is that we can use column (field) names longer than 10 characters. One feature we don’t like is that SQL creates ugly alternate names of 10 characters that we end up using in our RPG programs. Is there any way we can rename these ugly names?
–Paul
I know what you mean, Paul. If a column name is more than 10 characters long, SQL creates a shorter column name from the first five characters of the field name and a five-digit
-
More About Blocking
January 23, 2008 Hey, Ted
Don’t Disable Blocking was a good article. I would like to offer two suggestions for improvement.
First RPG ILE provides a BLOCK(*YES) file level keyword, which allows compiler-generated blocking when a random I/O operation is issued to a file processed sequentially using a READ. The most common scenario is “Keylist SETxx SomeFile” followed by READ. Note that READE is not treated as a sequential operation.
Second, I am a little disappointed that after your breakthrough OPNQRYF to SQL article using a SPECIAL device, you didn’t recommend the same approach for this situation. SQL automatically generates efficient blocking instructions for
-
Stuff I Didn’t Publish This Year
December 12, 2007 Ted Holt
Note: The code accompanying this article is available for download here.
My wife and I recently visited our local Cracker Barrel, which is one of our favorite restaurants. While we were waiting for our food, I picked up the peg game that unfailingly occupies patrons at the tables of that establishment and, for the umpteenth time, failed to solve it.
The Peg Game
In case you’re not familiar with a peg game, here’s how it works. The board has 15 holes arranged in a triangle and 14 of the holes are occupied by pegs. To
-
Create Multiple Directory Levels in One Swell Foop
December 5, 2007 Hey, Ted
Maybe I’m getting old, but I seem to remember being able to create several levels of directory structure with one command. I currently have such a need, in an application that creates XML files in the IFS. Yet CL’s MAKE DIRECTORY (MKDIR) command fails with error message CPFA0A9. Am I imaging things, or has something changed?
–Lynn
My guess is that you’re remembering MS-DOS’s md command. The following example contains a command that creates from one to five directories as needed.
C:>md salesreports2007 1RegionC
CL’s MKDIR command can only create one directory level at a time. However, Qshell’s mkdir command can
-
Update Only One of Duplicate Records
December 5, 2007 Hey, Ted
We have a file that has no unique key. This means that we sometimes get duplicate records in the file. This does not cause us problems in RPG programs because we can read a record, make changes to it, and update it, whether we’re using native I/O or an SQL cursor. However, having duplicate rows is a problem when we use SQL outside of programs. If two or more records are identical, there is no way to code a WHERE clause that will select only one record. Or is there?
–David
It is ugly, but possible, David. Assume table MYDATA,