Generators

Поиск
Список
Период
Сортировка
От Fernando Braga
Тема Generators
Дата
Msg-id 000b01bf05b5$8cb47780$0258c7c8@vcnet.com.br
обсуждение исходный текст
Список 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
 
Вложения

В списке pgsql-ports по дате отправления:

Предыдущее
От: Jordi Xavier Prat Grau
Дата:
Сообщение: postgresql port success ...
Следующее
От: Thomas Lockhart
Дата:
Сообщение: Re: [PORTS] NEWBIE needs help