Re: function return value inside a trigger function

From: "joao tiago a(dot) m(dot) viegas" <jtamviegas(at)yahoo(dot)co(dot)uk>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: function return value inside a trigger function
Date: 2012-10-07 22:52:42
Message-ID: CA+5hQH3T_PhTkDhzfZYrnUhy5GVBPjVfgzozTY+eCE06SUzqMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

sorry for the late update
thank you all,
I found the cause, that specific sentence was correct, it was in another
sentence of the same function, I think it was late at night and I was tired.

thank you anyway

best regards
jtv

On 27 September 2012 02:26, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> joao viegas <jtamviegas(at)yahoo(dot)co(dot)uk> writes:
> > does anybody knows how can I have something like:
> > select function_that_returns_int(NEW.field1) into NEW.field2;
>
> Works for me ...
>
> create table fooey (q1 int, q2 int);
>
> create function myt() returns trigger language plpgsql as $$
> begin
> select abs(new.q1) into new.q2;
> return new;
> end$$;
>
> create trigger mytrig before insert on fooey for each row
> execute procedure myt();
>
> insert into fooey values(-42, 77);
>
> select * from fooey;
> q1 | q2
> -----+----
> -42 | 42
> (1 row)
>
> Perhaps you should show a full example of what you're doing.
>
> regards, tom lane
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yvon Thoraval 2012-10-08 00:08:34 Re: [Mac OS X Mountain Lion] FATAL: could not create shared memory segment: Cannot allocate memory
Previous Message Sean Chittenden 2012-10-07 22:19:41 Re: 'full_page_writes=off' , VACUUM and crashing streaming slaves...