Re: After insert trigger not work - Mailing list pgsql-general

From Brilliantov Kirill Vladimirovich
Subject Re: After insert trigger not work
Date
Msg-id 5464C18D.509@byterg.ru
Whole thread Raw
In response to After insert trigger not work  (Brilliantov Kirill Vladimirovich <brilliantov@byterg.ru>)
List pgsql-general
Melvin Davidson wrote on 11/13/2014 05:29 PM:
> s for
> I suspect your problem is because you have 6 columns that are NOT NULL, but
> on INSERT you are only supplying values for 4 columns plus the id(serial).
> Therefore, the INSERT will fail. Perhaps if you supplied a value for
> last_update you it will work a lot better.

Hello, Melvin!
Why this is a problem is last_update column created with default value?

>> Trigger should update data in table:
>> CREATE TABLE trassa.ram_free_stat
>> (
>>    id serial NOT NULL,
>>    device integer NOT NULL,
>>    min_value integer NOT NULL,
>>    avg_value integer NOT NULL DEFAULT 0,
>>    max_value integer NOT NULL,
>>    last_update timestamp without time zone NOT NULL DEFAULT now(),
>>    CONSTRAINT ram_free_stat_pk PRIMARY KEY (id),
>>    CONSTRAINT ram_free_stat_device_fk FOREIGN KEY (device)
>>        REFERENCES trassa.devices (id) MATCH SIMPLE
>>        ON UPDATE NO ACTION ON DELETE NO ACTION,
>>    CONSTRAINT ram_free_stat_max_fk FOREIGN KEY (max_value)
>>        REFERENCES trassa.ram (id) MATCH SIMPLE
>>        ON UPDATE NO ACTION ON DELETE NO ACTION,
>>    CONSTRAINT ram_free_stat_min_fk FOREIGN KEY (min_value)
>>        REFERENCES trassa.ram (id) MATCH SIMPLE
>>        ON UPDATE NO ACTION ON DELETE NO ACTION
>> )
>>



--
Best regards,
Brilliantov Kirill Vladimirovich


pgsql-general by date:

Previous
From: Ted Toth
Date:
Subject: Re: sepgsql where are the security labels
Next
From: Russell Keane
Date:
Subject: Data corruption