In this tip I'll explain how to define a sequence number column to a table that gets populated by the system every time a record is added to that table.
This could be achieved by defining an identity column to that table.
The following example will create a table named TableName with one identity column SEQNUM and a character column Column2. SEQNUM will be the primary key for the new table.
SEQNUM values will be 1, 2, 3, 4, . .... ., 999999999999999.
Create Table TableName (SEQNUM NUMERIC (15, 0) not null generated always as identity (start with 001 increment by 1), column2 char (03) not null with default, primary key (seqnum))
To insert a record:
Insert into QGPL/tablename (column2) values('ABC')
The data in the table after running the insert statement three times:
SEQNUM COLUMN2 1 ABC 2 ABC 3 ABC