I would strongly advise you to use SEQUENCEs. That is idiomatic Ingres approach (actually, sequences are SQL:2003 standard, if I remember well, so every good RDBMS which supports SQL should support them).
Unfortunately Actian moved the documentation to a new system which makes it very difficult to create a direct link to a page describing something, so I can't really give you a link here. Please go to http://docs.actian.com , pick Ingres 10 docs (in Options), and open the SQL reference.
In short, make a sequence called, say TBL_REFS_SEQ
:
CREATE SEQUENCE TBL_REFS_SEQ; -- Also grant it
Then you can do something like:
UPDATE TBL_REFS
FROM TBL_USETHISID
SET nextid = TBL_REFS_SEQ.NEXTVAL;
Sequence also has the CURVAL
property.
NOTE: Keep in mind that you need to grant privileges to this newly created sequence if you want it to be accessable by certain users/roles.
From the Ingres 10.0 SQL Reference Guide:
A NEXT VALUE or CURRENT VALUE expression on a particular sequence is evaluated once per row inserted by an INSERT statement, updated by an UPDATE statement, or added to the result set of a SELECT statement. If several occurrences of a NEXT VALUE or CURRENT VALUE expression on the same sequence are coded in a single statement, only one value is computed for each row touched by the statement. If a NEXT VALUE expression and a CURRENT VALUE expression are coded on the same sequence in the same statement, the NEXT VALUE expression is evaluated first, then the CURRENT VALUE expression (assuring they return the same value), regardless of their order in the statement syntax.