Re: auto-increment integer field for each row

Поиск
Список
Период
Сортировка
От Lonni J Friedman
Тема Re: auto-increment integer field for each row
Дата
Msg-id 7c1574a90912031522w6cbeb5bcnedec43ec40641703@mail.gmail.com
обсуждение исходный текст
Ответ на Re: auto-increment integer field for each row  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
On Thu, Dec 3, 2009 at 2:56 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Lonni J Friedman <netllama@gmail.com> writes:
>> I tried to use the trigger example here, but it silently fails to work:
>> http://archives.postgresql.org/pgsql-sql/2000-02/msg00147.php
>
> That example seems to be lacking a CREATE TRIGGER command, so
> there's nothing telling the system to call the function.
> It never worked as given --- read the whole thread.

I thought that I had read the whole thread, but never saw any mention
of a missing 'create trigger' command.  Anyway, once I created the
trigger, it worked perfectly.  For the sake of posterity, the create
trigger command that I used was (my table name is appstracker, and my
function name is appstracker_incrementer) :

create trigger appstracker_incrementer_trigger before update on
appstracker FOR EACH ROW EXECUTE PROCEDURE appstracker_incrementer() ;

>
> The only really out-of-date part of it is that nowadays
> "returns trigger" is preferred to "returns opaque".
> But you need CREATE TRIGGER.

And its even nice enough to warn me about this:
WARNING:  changing return type of function appstracker_incrementer
from "opaque" to "trigger"
CREATE TRIGGER

thanks Tom!

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: auto-increment integer field for each row
Следующее
От: A B
Дата:
Сообщение: Is autovaccum lazy?