Re: Shorthand syntax for triggers - Mailing list pgsql-general

From Sergey Konoplev
Subject Re: Shorthand syntax for triggers
Date
Msg-id CAL_0b1uZzehYCvg3GcUydz9vDUiqSrFUOxCPT13SmYe46KG46w@mail.gmail.com
Whole thread Raw
In response to Re: Shorthand syntax for triggers  (Moshe Jacobson <moshe@neadwerx.com>)
List pgsql-general
On Mon, Oct 15, 2012 at 11:36 AM, Moshe Jacobson <moshe@neadwerx.com> wrote:
>> IF TG_OP = 'DELETE' THEN RENAME OLD TO myrow;
>> ELSE RENAME NEW TO myrow; END IF;
>
> Does the RENAME syntax actually work? My understanding is that it has been
> broken for a long time.

Oh, you got a point! It does not work since 9.0. I forget it, sorry.

Another way to do it is:

DECLARE
    myrow record;
    ...
BEGIN
    myrow := CASE WHEN TG_OP = 'DELETE' THEN OLD ELSE NEW END;
    ...

--
Sergey Konoplev

a database and software architect
http://www.linkedin.com/in/grayhemp

Jabber: gray.ru@gmail.com Skype: gray-hemp Phone: +14158679984


pgsql-general by date:

Previous
From: Moshe Jacobson
Date:
Subject: Re: Shorthand syntax for triggers
Next
From: "Daniel Serodio (lists)"
Date:
Subject: Is pg_basebackup also for "regular" backups?