• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Use Field Names for Column Headings

    May 11, 2005 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

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Computer Lab and BOSaNOVA Bolster Thin Clients Help/Systems New CSI Tracks Down Runaway Jobs

    Leave a Reply Cancel reply

Volume 5, Number 19 -- May 11, 2005
THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
WorksRight Software
Linoma Software

Table of Contents

  • Use Field Names for Column Headings
  • Viewing and Printing the Euro Symbol
  • Scanning QSYSOPR for Selected System Messages

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle