Sirs,
I'm migrating an Interbase database to Postgres, and I'm stuck on a generator problem. There is an auto-sequencing field, which is automatically increased every time a new record is inserted. In Interbase, I issued a CREATE GENERATOR command, and a CREATE TRIGGER, just like this:
CREATE GENERATOR <table> <generatorname>;
SET TERM ^;
CREATE TRIGGER <triggername> FOR <table>
ACTIVE BEFORE INSERT POSITION 0 AS BEGIN
NEW.<fieldname> = GEN_ID( <generatorname>, 1 );
END
^
COMMIT WORK ^
SET TERM ;^
I have studied Postgres a while and I haven't found a way to do so. Could you please point me a way to accomplish that ? Is it necessary for me to every time query the database for the largest number and insert this incremented number? And for heavy-loaded databases ?
Sincerely,
Fernando Braga