On 5/22/19 3:21 PM, PegoraroF10 wrote:
sorry, I wasn´t clear, when I sad returning Null I tried to say that new.PK
was Null, not the function result > Try to create exactly what I sent you and you´ll see null values on
that pk.
Yes because FOR EACH STATEMENT may deal with multiple rows, so it is
undefined what NEW.pk is referring to.
More below.
And that occurs just because that trigger was created without EACH
ROW/STATEMENT.
So, my question is, PG should return an error and not create that trigger
because ROW/STATEMENT was not specified, correct ?
It was implicitly specified. Per the docs it will be FOR EACH STATEMENT
by default in the absence of user input.
If you just need the new PK why not?:
INSERT INTO some_table ... RETURNING pk;
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx