Sometimes, you run a query on a file, and it turns out that the columns have no headings. That is, no meaningful headings-only cryptic field names of no more than 10 characters. What can you do to stop this problem from occurring again? It's unlikely that you'll want to change the DDS for the file (adding suitable COLHDG keywords to all fields) and re-create the file, because such recreation means potentially losing all data in the file. You can do it by cloning the file, recreating the original, and moving all the data back-but you still have logical files to worry about.
There's a better solution: SQL's LABEL ON statement. Simply put, it adds either column headings or text description (TEXT keyword) to database fields. You can execute the LABEL ON statement either from an interactive SQL session, started with the Start SQL command (STRSQL), or from a Query Management Query, started with the Start Query Management Query (STRQMQRY) command.
The key is in knowing how LABEL ON's syntax goes. Let's see this by way of two examples. Suppose file CONTACTS has a field named FAXNBR but no column headings, and a field named TELNBR but no text description. The SQL statement in Figure 1 fixes the first problem.
As you can see, you have to list in parentheses the fields that are to be labeled, separating them by commas. For each field, use the TEXT reserved word to add text description; for column headings, simply omit it. In the case of column headings, bear in mind that whatever character string you supply will be processed as follows:
o The first 20 characters represent the first line of column headings.
o The second 20 characters represent the second line of column headings.
o The last 20 characters represent the third line of column headings.
Changes made by the LABEL ON statement are permanent. Even so, it is a good idea to go back to the DDS of the file and add appropriate COLHDG and/or TEXT keywords, just in case you
ever recompile.
- Allan Telford
Distribution Service Technologies
714-474-4043
Figure 1: SQL statement
LABEL ON contacts (faxnbr IS 'Fax Number',
faxnbr TEXT IS 'Work fax number',
telnbr IS 'Telephone Number',
telnbr TEXT IS 'Work telephone number')
LATEST COMMENTS
MC Press Online