Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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:
> 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"

thanks Tom!

In response to

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group