Re: Refreshing functional index

From: Grzegorz Tańczyk <goliatus(at)polzone(dot)pl>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: 'Merlin Moncure' <mmoncure(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Refreshing functional index
Date: 2012-10-08 22:06:26
Message-ID: 24302428.409651349733781664.JavaMail.root@Polzone
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"BEFORE INSERT" was the problem here, "AFTER INSERT" works fine

Thanks for all answers.

--
Regards,
Grzegorz

W dniu 2012-08-31 20:41, Grzegorz Tańczyk pisze:
> Hello,
>
> W dniu 2012-08-31 20:25, David Johnston pisze:
>> The question becomes how do you update the "item id" on the "groups"
>> table when you add new records to "items".
>
> I have a trigger on items table:
>
> CREATE TRIGGER items_insert
> BEFORE INSERT
> ON items
> FOR EACH ROW
> EXECUTE PROCEDURE items_oninsert();
>
> CREATE OR REPLACE FUNCTION items_oninsert()
> RETURNS trigger AS
> $BODY$
> BEGIN
> UPDATE groups SET last_item = NEW.id WHERE id=NEW.group AND
> (last_item IS NULL OR last_item<NEW.id);
> RETURN NEW;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
>
> Thanks!
>
> --
> Regards,
> Grzegorz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yvon Thoraval 2012-10-08 22:21:14 Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory
Previous Message Seref Arikan 2012-10-08 21:59:21 Re: Suggestions for the best strategy to emulate returning multiple sets of results