Re: After insert trigger not work

From: Brilliantov Kirill Vladimirovich <brilliantov(at)byterg(dot)ru>
To: Melvin Davidson <melvin6925(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: After insert trigger not work
Date: 2014-11-13 14:34:53
Message-ID: 5464C18D.509@byterg.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Russell Keane 2014-11-13 14:40:31 Data corruption
Previous Message Ted Toth 2014-11-13 13:58:23 Re: sepgsql where are the security labels