Home > Ask the AS/400 Experts > DB2/400 and DB2 UDB Questions & Answers > Using SQL syntax to override DB2 automatic column name generator on iSeries
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Using SQL syntax to override DB2 automatic column name generator on iSeries

Kent Milligan EXPERT RESPONSE FROM: Kent Milligan

Pose a Question
Other iSeries 400 Categories
Meet all iSeries 400 Experts
Become an Expert for this site


iSeries news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 29 April 2008
In production, we never drop and recreate tables. In test we do. Recently, we used the ALTER statement to remove a column in the table. The column removed seemed to have the internal name of MAX_P00001. In the production table there is still a MAX_P00002 and a MAX_P00003. In test tables, because we recreate the tables, there is a MAX_P00001 and a MAX_P00002. Since we have a common I/O program, if we restore the production version of the table into a test library we get a -901 error on the select. If we recompile the I/O program into the test library, containing the restored table, it works. Can we do something other than drop and recreate the production table to force the internal names to MAX_P00001 and 2?

>
EXPERT RESPONSE
The best solution in this case would be to use special SQL syntax to explicitly control the short, internal name instead of relying on DB2's column name generator. Here's an example of using the 'FOR COLUMN' clause to explicitly specify a short, internal name instead of having DB2 generate that identifier.

CREATE TABLE test1 (longlongname FOR COLUMN shortname CHAR(4))


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
DB2/400 and DB2 UDB
Auditing: RPG with embedded SQL showing up as a changed object
Selecting a PF with multiple members from SQL
Referencing a renamed column on SELECT clause in SQL
Using WebSphere information integrator to access MS server data using SQLRPGLE
Joining files using SQLRPGLE
Querying system catalog tables to determine table alias
Excluding characters from AS/400 DB2 SELECT statements prevents mapping errors
How to use the QQQVEXPL API
Making a file with an automatic key in iSeries with DDS keyword
The SETOBJACC command

iSeries SQL commands and statements
Selecting a PF with multiple members from SQL
Referencing a renamed column on SELECT clause in SQL
How to use an embedded SQL statement and display the result in a subfile
Blocking access to SQL line commands
Joining files using SQLRPGLE
Querying system catalog tables to determine table alias
Excluding characters from AS/400 DB2 SELECT statements prevents mapping errors
Making a file with an automatic key in iSeries with DDS keyword
Using SQL on System i to color source code and inline comments
The SETOBJACC command
iSeries SQL commands and statements Research

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



iSeries Networking - Printing, Remote Access, TCP/IP
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts