Harold L. Brown February 2016

"x FOR y" in column definition of DB2 create table statement

This is the DB2 create table statement:

CREATE TABLE SCHEMA_F.TABLE_A (
    LEAFDESCRIPTION FOR F7UY2 CHAR(10) CCSID 1141  NOT NULL WITH DEFAULT
    ...

What does LEAFDESCRIPTION FOR F7UY2 mean exactly?

Answers


Clockwork-Muse February 2016

tl;dr

It allows you to specify the short name usable from (older) RPG programs on the i and some system utilities. In this case, LeafDescription is the long name usable from SQL, and F7UY2 usable inside RPG, etc (and SQL, but long names are usually preferred for obvious reasons).


It's part of the system-specific behavior available on the i.

See, the i (iSeries, Systemi, AS/400) started out as a very different machine. Several decades ago, before SQL was really a thing. And at the time, field and table names were limited to around 6 characters, and programs were written with this in mind.

Now, flash forward to when SQL comes around. On the i, DB2 SQL got retrofitted (of a sort) on top of the existing file system. This meant that, among other things, you could query over your existing files with SQL without recreating or repopulating them.
Unfortunately, it also meant they were stuck with the original, semi-cryptic names, in part because you still had all the original programs too. If you created (or re-created, as the case may be) a table via SQL, RPG programs couldn't reference it. So this allowed you to specify a name it could reference - which meant you could switch to SQL-based tables (which had some additional, new, advantages) without needing to change your programs. Even with the name-length restriction being lifted in recent versions of RPG, the ability to avoid renaming everything all at once is a boon.

Post Status

Asked in February 2016
Viewed 1,069 times
Voted 9
Answered 1 times

Search




Leave an answer