460 pts.
 GENERATED KEYS…
I want to generate the next avalable key when INSERTing new rows. For an example... Create Table DBALIB/PARENT ( PARKEY BIGINT NOT NULL WITH DEFAULT PRIMARY KEY, PARNAME CHAR (30) NOT NULL WITH DEFAULT); INSERT INTO PARENT ( PARKEY, PARNAME) VALUES ( PARKEY(MAX) + 1), (<=====> just for illustration) 'BOBBY')

Software/Hardware used:
ASKED: January 8, 2007  12:02 PM
UPDATED: January 8, 2007  2:04 PM

Answer Wiki:
In DB2: Create your field with attributes INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT BY 1) Or, replace NOT NULL with PRIMARY KEY. Don't call out the field in the INSERT field list. In Oracle, declare a sequence, and then use .NEXTVAL. --- Sheldon Linker (sol@linker.com) Linker Systems, Inc. (www.linkersystems.com) 800-315-1174 (+1-949-552-1904)
Last Wiki Answer Submitted:  January 8, 2007  2:04 pm  by  SheldonLinker   15 pts.
All Answer Wiki Contributors:  SheldonLinker   15 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _