Newsletters   Subscriptions  Forums  Store   Career  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 5, Number 19 -- May 11, 2005

Use Field Names for Column Headings


by Ted Holt


SQL/400 SELECT statements use the column headings that are stored as part of the file description when displaying or printing data. Sometimes I prefer to see the field names themselves used as column headings. I have found one method to make SQL use field names as column headings, but I wonder if you know of a better one.

--Danny

Danny is referring to files that are created with DDS, although column headings may also be defined with SQL's LABEL ON command. Here's an example of a few fields with defined column headings.











A                                      UNIQUE
A          R CUSTREC
A            COMPANY        3P 0B      TEXT('Company')
A                                      DFT(1)
A                                      COLHDG(' ' ' ' 'Company')
A                                      EDTCDE(1)
A            CUSTNBR        5P 0B      TEXT('Customer account number')
A                                      COLHDG('Customer' ' account' +
A                                      '  number')
A                                      EDTCDE(4)
A            CUSTNAME      20   B      TEXT('Customer name')
A                                      COLHDG(' ' 'Customer' 'name')
A                                      ALWNULL

Here's a simple select against those fields.

SELECT COMPANY, CUSTNBR, CUSTNAME
      FROM SOMEFILE

Selecting these fields shows output like the following:

          Customer
           account  Customer
 Company    number  name
     1      20304   BIL'S GROCERY
     1      30405   TOM'S PHARMACY

Danny's method is to rename each field with its own name.

SELECT COMPANY AS COMPANY, CUSTNBR AS CUSTNBR,
      CUSTNAME AS CUSTNAME
      FROM SOMEFILE

Renaming in this manner produces the following output.

COMPANY  CUSTNBR  CUSTNAME
    1     20304   BIL'S GROCERY
    1     30405   TOM'S PHARMACY

I don't know of any setting that tells SQL to use field names for column headings, so I do not have a better method than the one Danny is using.


SQL/400 also picks up other formatting options from the file description. I have found it helpful to define edit codes and edit words in DDS, so that queried data is formatted nicely. For example, over an eight-digit, numeric field that contains a date in YYYYMMDD format, the following edit word is helpful.

EDTWRD('    /  /  ')

There are four blanks before the first slash for the year, two blanks between the slashes for the month, and two blanks after the second slash for the day. The value 20051231 displays as 2005/12/31.

--Ted

Sponsored By
ADVANCED SYSTEMS CONCEPTS

SEQUEL can be used for virtually ALL data access functions on the iSeries.

A Windows-based user interface makes it easy to design queries and reports.

SEQUEL offers executive dashboards, drill-down data analysis and run-time prompts to deliver important iSeries data to managers and other non-technical users.

E-mail and FTP delivery let you deliver information to remote users and servers.

www.asc-iseries.com


Technical Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Contributing Technical Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
WorksRight Software
Linoma Software


Four Hundred Guru

BACK ISSUES

TABLE OF
CONTENTS
Use Field Names for Column Headings

Viewing and Printing the Euro Symbol

Scanning QSYSOPR for Selected System Messages


The Four Hundred
iSeries SNA Software Support Continues with Enterprise Extender

IBS to Port OS/400 Apps to Unix, Windows, and Linux

IBM to Cut Up to 13,000 Employees, Mostly in Europe

As I See It: IT, the Early Days

Four Hundred Stuff
SSA Delivers New ERP LX Platform for iSeries

LANSA User Conference Puts New App Modernization IDE in Spotlight

Scriptura XBOS 4.0 Delivers Flexibility for Business Documents

Computer Lab and BOSaNOVA Bolster Thin Clients

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc. (formerly Midrange Server), 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement