fhg
Volume 8, Number 5 -- February 6, 2008

Don't Let SQL Name Your Baby

Published: February 6, 2008

Hey, Ted:

We have started using SQL Data Definition Language (DDL) to define our physical files. One feature we really like is that we can use column (field) names longer than 10 characters. One feature we don't like is that SQL creates ugly alternate names of 10 characters that we end up using in our RPG programs. Is there any way we can rename these ugly names?

--Paul


I know what you mean, Paul. If a column name is more than 10 characters long, SQL creates a shorter column name from the first five characters of the field name and a five-digit sequence number. For example, look at this DDL.

create table SomeTable                                       
  (ID integer,                                                
   Name varchar(20),                                         
   PreferredName varchar(20))                                

The generated fields would be known as ID, NAME, and PREFE00001 in RPG programs. If you want to use a different shorter name than PREFE00001, include FOR COLUMN in the column definition.

create table SomeTable2                                      
  (ID integer,                                                
   Name varchar(20),                                         
   PreferredName for column prefname varchar(20))            

RPG programs will refer to the third field as PREFNAME.

--Ted




Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, Inc., 50 Park Terrace East, Suite 8F, New York, NY 10034

Privacy Statement