how to make a field in record auto-increment ?
Posted in 1999
Topics: General Discussion
Hi, I am new to informix database running in unix, how do i set a particular field within a record to autoincrement and read only ? The field is of a string type running in accending order from "B1,B2... onwards" Any help is appreciated. regard Andrew
Two aproaches:
For numeric autoincrement fields there is a SERIAL type:
CREATE TABLE mytab(col SERIAL);
INSERT INTO mytab VALUES(0);
INSERT INTO mytab VALUES(0);
INSERT INTO mytab VALUES(0);
INSERT INTO mytab VALUES(0);
every insert increases the value inserted on col column.
For character column autoincrement you should doit by external program or
with a procedure.
Vicente Salvador
DEISTER, S.A. (Spain)
Andrew Ng wrote:
> Hi,
> I am new to informix database running in unix, how do i set a particular
> field within a record to autoincrement and read only ?
> The field is of a string type running in accending order from "B1,B2...
> onwards"
> Any help is appreciated.
>
> regard
> Andrew
> Hi, > I am new to informix database running in unix, how do i set a particular > field within a record to autoincrement and read only ? > The field is of a string type running in accending order from "B1,B2... > onwards" > Any help is appreciated. > I never saw any type definition to support what you want. An alternative solution is using serial as your field type, and using application to attach the char you want when displaying. ----------------------------------------------------------- Proton Kao proton@iii.org.tw