Generators

From: "Fernando Braga" <fmbraga(at)sincro(dot)com(dot)br>
To: <pgsql-ports(at)postgresql(dot)org>
Subject: Generators
Date: 1999-09-23 11:19:46
Message-ID: 000b01bf05b5$8cb47780$0258c7c8@vcnet.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-ports

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

Browse pgsql-ports by date

  From Date Subject
Next Message Thomas Lockhart 1999-09-23 13:40:56 Re: [PORTS] NEWBIE needs help
Previous Message Jordi Xavier Prat Grau 1999-09-23 11:03:09 postgresql port success ...