Problem solve Get help with specific problems with your technologies, process and projects.

Use the SQL Rename command to make everyone happy

Working with the SQL Rename command.

As DBA, I support both server-side iSeries programmers (RPG & C) and client-side programmers (Java).

When defining new database tables in SQL, the Java programmers usually prefer really long table-names like MyReallyLongTableName. Unfortunately, this makes the server-side programmers coding more difficult, because it translates that long name into a system name of MYREA00001. Similarly, MyReallyUsefulTable translates into MYREA00002.

This can even lead to problems later when MyReallyUsefulTable get defined in another environment. If MyReallyLongTableName doesn't exist in that environment, then MyReallyUsefulTable becomes MYREA00001. You can see how this can cause bugs and confusion since it now has a DIFFERENT system name in this environment.

The following SQL code makes everybody happy because it defines a "static" short 10-character name for the tables (and record-format and member and columns), AND it allows the Java programmers to have their descriptive long name.

   
  CREATE TABLE LongName (
  LongFieldName1 FOR COLUMN LFN1 INTEGER NOT NULL,
  LongFieldName2 FOR COLUMN LFN2 CHAR(3) NOT NULL,
  CONSTRAINT LongFileName0 
      PRIMARY KEY (LongFieldName1)
);

RENAME TABLE LongName TO LongTableName FOR SYSTEM NAME LongName; 

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.


Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close