Re: Unique identifiers
Posted in 1996
> Does Informix have a built-in function to generate unique ID-numbers? I
> need to be sure that I get a different number each time I call the
> function, because the values are to be entered into a column with an
> unique index.
Informix has a built-in datatype called SERIAL that will do this automatically.
You would typically create your table like this:
CREATE TABLE mytab (
key_col SERIAL(1) PRIMARY KEY,
.
.
.
.
)
and then insert into the table like this:
INSERT INTO mytab VALUES (0, .....)
The engine will then automagically increment the counter for you. You will
be able to inspect the number allocated by checking the contents of the
built-in variable SQLCA.SQLERRD[2] after the insert.
HTH.
--
Ciao,
Billy
+------------------------------------------------------------------------------+
| Billy Wheeler Junior Programmer / Director The West Solutions Group |
+------------------------------------------------------------------------------+
| Oracle isn't the answer. Oracle is the question, and the answer is "no". |
+------------------------------------------------------------------------------+