pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Igal @ Lucee.org <igal@lucee.org>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Trigger function does not modify the NEW value
Date: Fri, 28 Jun 2019 19:53:50 -0700
Message-ID: <04592c40-829d-a31e-790a-96afbc108c0a@lucee.org> (raw)

I have a trigger that is created like so:

     create trigger tr_on_table_modified after insert or delete or update
         on some_table for each row execute procedure on_table_modified();

     CREATE OR REPLACE FUNCTION on_table_modified() RETURNS trigger 
LANGUAGE plpgsql $$
         /* some code that does not modify any values but calls PERFORM 
on another function */

         raise notice 'lowercasing %', new.email;
         new.email = lower(new.email);
         raise notice '    to %', new.email;

         return new;
     $$

I can see in the output the notices with the expected values, but the 
value in the updated record is not lower-cased.

update some_table
set    email = 'IGAL@Lucee.org'
where  id = 1;

 > 00000: lowercasing IGAL@Lucee.org
 > 00000:     to igal@lucee.org

select email
from   some_table
where  id = 1;

 > email         |
 > --------------|
 > IGAL@Lucee.org|

Any ideas?

Thanks,

Igal Sapir
Lucee Core Developer
Lucee.org <http://lucee.org/;

view thread (3+ messages)  latest in thread

Message-ID: <04592c40-829d-a31e-790a-96afbc108c0a@lucee.org>
Permalink:  ../04592c40-829d-a31e-790a-96afbc108c0a@lucee.org/
Also on:    postgresql.org/message-id/04592c40-829d-a31e-790a-96afbc108c0a@lucee.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: igal@lucee.org
  Subject: Re: Trigger function does not modify the NEW value
  In-Reply-To: <04592c40-829d-a31e-790a-96afbc108c0a@lucee.org>
  References: <04592c40-829d-a31e-790a-96afbc108c0a@lucee.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox