Home > Ask the AS/400 Experts > DB2/400 and DB2 UDB Questions & Answers > Making a file with an automatic key in iSeries with DDS keyword
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Making a file with an automatic key in iSeries with DDS keyword

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: 28 April 2008
I need a file with an automatic key in it on the iSeries. I know you can create one using SQL but is there a keyword in DDS that can be used for this? Would I have to use the following code in an RPGLESQL program to do this?

CREATE TABLE invoice_data
(invoice# INTEGER NOT NULL
GENERATED ALWAYS AS IDENTITY
(START WITH 1
,INCREMENT BY 1
,NO MAXVALUE
,NO CYCLE
,ORDER)
,sale_date DATE NOT NULL
,customer_id CHAR(20) NOT NULL
,product_id INTEGER NOT NULL
,quantity INTEGER NOT NULL
,price DECIMAL(18,2) NOT NULL
,PRIMARY KEY (invoice#));


>
EXPERT RESPONSE
The Identity column attribute is only available to SQL-created tables. However, the good news is that although there's no DDS support, any native writes performed against an SQL table created with an identity table will result in DB2 generating identity values. Any SQL table created with an identity column will generate identity values for both SQL and non-SQL I/O interfaces.


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


RELATED CONTENT
DB2/400 and DB2 UDB
Running source member SQL statements with RUNSQLSTM
Enabling IBM i to access Microsoft SQL server data
Using SQL to search within a DB2 field on IBM i
Controlling a library list on a remote system
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

iSeries SQL commands and statements
Running source member SQL statements with RUNSQLSTM
Enabling IBM i to access Microsoft SQL server data
Using SQL to search within a DB2 field on IBM i
Controlling a library list on a remote system
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
iSeries SQL commands and statements Research

DB2 UDB (universal databases)
How to: Sort arrays using RPGIV
Debating DB2 versus Oracle
IBM i news updates for the week of 10/13/2008
Auditing: RPG with embedded SQL showing up as a changed object
DB2 on AS/400: What has it done for me lately?
How to: Transfer unlimited data to Excel from AS/400
What is an integrated database?
An automated CL method of moving a query from AS/400 to Excel
Using WebSphere information integrator to access MS server data using SQLRPGLE
Querying system catalog tables to determine table alias
DB2 UDB (universal databases) 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