Re: How to get next serial value
Posted in 1997
Rory Reynoldson wrote:
>
> Quick question about Informix's serial datatypes (I'm used to working
> with Oracle sequences).
>
> In Oracle, I would have a table OTAB (fld1 number) and sequence
> OTAB_SEQ and insert as:
> insert into OTAB (fld1) values (OTAB_SEQ.nextval);>
> In Informix, I would have a table ITAB (fld1 serial) and insert as:
> insert into ITAB (fld1) values (0);>
> Both give me unique numbers...
>
> But, in Oracle if I want the unique number before the insert I would
> do:
> select OTAB_SEQ.nextval from dual;> and the insert becomes
> insert into OTAB (fld1) values (:some_var);>
> Is there a similar thing to do in Informix? Basically I want the
> unique number without inserting and then reselecting to retrieve the
> unique number
Rory,
So ya doesen't wanna insert yet; you only want to know what the next
value will be next time you insert. Try the following in dbaccess; you
can adapt it to you application.
database stores;
select tabname, ti.ti_serialv
from systables st, sysmaster:systabinfo ti
where ti.ti_partnum = st.partnum
and st.tabname = "customer";
--
-- Jake (In pursuit of undomesticated aquatic avians)
+---------------------------------------------------------------+
|Insofar as manifestations of functional deficiencies are agreed|
|by any and all concerned parties to be imperceivable, and are |
|so stipulated, it is incumbent upon said heretofore mentioned |
|parties to exercise the deferment of otherwise pertinent |
|maintenance procedures. |
+------------------- A Legal Minded Engineer (hardyharhar.com) -+