Brilliantov Kirill Vladimirovich wrote:
>> You should post the table definition and the whole trigger; the error
>> message seems to refer to things you omitted in your quote.
>
> Table with statistic:
> CREATE TABLE trassa.cpu_load_stat
> (
> id serial NOT NULL,
> device integer NOT NULL,
> cpu smallint NOT NULL,
> min_value smallint NOT NULL,
> min_device_timestamp timestamp without time zone NOT NULL,
> min_timestamp timestamp without time zone,
> avg_value smallint NOT NULL,
> avg_timestamp timestamp without time zone NOT NULL,
> max_value smallint NOT NULL,
> max_device_timestamp timestamp without time zone NOT NULL,
> max_timestamp timestamp without time zone,
> total_value bigint NOT NULL,
> total_count integer NOT NULL,
[...]
> )
> Trigger:
> CREATE OR REPLACE FUNCTION trassa.update_cpu_load_stat()
> RETURNS trigger AS
> $BODY$
[...]
> UPDATE trassa.cpu_load_stat
> SET min_value = cpu_min_value,
> min_device_timestamp = cpu_min_device_timestamp,
> min_timestamp = cpu_min_created_timestamp,
> avg_value = CEIL((total_value + NEW.value) /
> (total_count + 1)),
> avg_timestamp = NOW(),
> max_value = cpu_max_value,
> max_device_timestamp = cpu_max_device_timestamp,
> max_timestamp = cpu_max_created_timestamp,
> total_value = (total_value + NEW.value),
> total_count = (total_count + 1)
> WHERE id = line_id;
I'd say that the error message refers to this or the following query:
There is no field "value" in the table, and "NEW" represents a row in the table,
so the expression "NEW.value" does not make sense.
Yours,
Laurenz Albe