Re: Shorthand syntax for triggers

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: Moshe Jacobson <moshe(at)neadwerx(dot)com>
Cc: Joe Van Dyk <joe(at)tanga(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Shorthand syntax for triggers
Date: 2012-10-15 19:26:33
Message-ID: CAL_0b1uZzehYCvg3GcUydz9vDUiqSrFUOxCPT13SmYe46KG46w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 15, 2012 at 11:36 AM, Moshe Jacobson <moshe(at)neadwerx(dot)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(dot)ru(at)gmail(dot)com Skype: gray-hemp Phone: +14158679984

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Serodio (lists) 2012-10-15 20:15:17 Is pg_basebackup also for "regular" backups?
Previous Message Moshe Jacobson 2012-10-15 18:36:08 Re: Shorthand syntax for triggers