Search Postgresql Archives

Trigger problem, record "new" is not assigned yet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

I'm probably doing some very basic error here, but I get

ERROR:  record "new" is not assigned yet
  The tuple structure of a not-yet-assigned record is indeterminate.

when I try this small example

create table foo(x int);

create or replace function trigger_foo() returns trigger language plpgsql as $$
declare v_i integer;
begin
    select count(1) into v_i from foo;
    if new.x >18 then
        raise exception 'error';
    else
        return null;
    end if;
end; $$;

CREATE TRIGGER trigger_foo AFTER INSERT ON foo for each row EXECUTE
PROCEDURE trigger_foo();

insert into foo (x) values (15);


And the table foo only have 14 lines right now.

Can someone help me spot the error? :-)

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux