Re: auto-increment integer field for each row

From: Lonni J Friedman <netllama(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: auto-increment integer field for each row
Date: 2009-12-03 23:22:52
Message-ID: 7c1574a90912031522w6cbeb5bcnedec43ec40641703@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Dec 3, 2009 at 2:56 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Lonni J Friedman <netllama(at)gmail(dot)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!

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message A B 2009-12-05 08:36:16 Is autovaccum lazy?
Previous Message Tom Lane 2009-12-03 22:56:06 Re: auto-increment integer field for each row