Is the use of Field Reference Files still relevant?
Is obfuscating the name of columns by adding a character to 3 indicating
the table of origin still necessary, or even desirable?
Since V3R1 of the operating system we've had the database cross reference
files. These evolved into views like SYSCOLUMNS, SYSTABLES, etc. Very
similar to what developers from other platforms are familiar with. So why
would we even want field reference files? I suppose if you just had to
have a field reference file, use SYSCOLUMNS.
Since we have SYSCOLUMNS, and if we didn't obfuscate columns by adding some
character prefix for table of origin, we can easily do a
select SYSTEM_COLUMN_NAME, SYSTEM_TABLE_NAME, SYSTEM_TABLE_SCHEMA
from qsys2.syscolumns
where SYSTEM_COLUMN_NAME = 'CUSTORDER';
But we screw it all up by having names like HORD, LORD, ... with that
leading character indicating file of origin.
In sql it's quite easy to do SELECT MYTABLE.CUSTARD... to flag the table.
In RPG there are several ways to do it
The following example adds the prefix "NEW_" to the beginning of the field
names for file NEWFILE, and the prefix "OLD_" to the beginning of the field
names for file OLDFILE.
Fnewfile o e disk prefix(NEW_)
Foldfile if e disk prefix(OLD_)
Here's another sample
**FREE
DCL-F ech DISK(*EXT) PREFIX('ECH_');
READ ech;
dsply ECH_hord;
*inlr = *on;
return;
On Tue, Sep 23, 2025 at 1:12 PM Rob Berendt <robertowenberendt@xxxxxxxxx>
wrote:
I do not believe you can do anything like the following:
alter table rob.m0923
add column (select ech.hord from erplxf.ech)
;
As an Amazon Associate we earn from qualifying purchases.