I've looked everywhere in the last 3 hours but still can't get this to work. I need to be able to concatenate the 1prefix and 1suffix value to form an id consisting of string and number.
How do I define the table.
create table dicounts_list
(
DISCOUNT_PREFIX CHAR(20) NOT NULL WITH DEFAULT 'DISC',
DISCOUNT_SUFFIX INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 0001, INCREMENT BY 1),
DISCOUNT_ID CHAR --concatenated values of DISCOUNT_PREFIX and DISCOUNT_SUFFIX e.g DISC0001
DISCOUNT_NAME VARCHAR(30) NOT NULL,
PRIMARY KEY(DISCOUNT_ID)
);
I need to be able to generate
DISC0001 DISC0002 DISC0003
on which only the numbers auto-increment every insertion to DiscounName. I just want to prefix the primary key with "DISC" as discount identifier.
I'm using Derby. I would really appreciate if you can help me with this or provide with alternative solution.
Thanks.