Q
Get started Bring yourself up to speed with our introductory content.

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

If you want to create an automatic key using a DDS keyword on AS/400, Kent Milligan explains that any native writes performed against an SQL table created with an identity table will result in DB2 generating identity values.

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#));

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.
This was last published in May 2008

Dig Deeper on iSeries SQL commands and statements

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close