Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-17 Thread Brilliantov Kirill Vladimirovich
Hello! After modify trassa.update_cpu_load_list function on inserting one line per time trigger work fine. CREATE OR REPLACE FUNCTION trassa.update_cpu_load_list(device_id integer, device_timestamp integer, device_cpu smallint[], device_cpu_load smallint[]) RETURNS boolean AS $BODY$ DECLAR

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-17 Thread Brilliantov Kirill Vladimirovich
Jim Nasby wrote on 11/15/2014 07:57 AM: Something else to consider: using FOUND to decide whether to INSERT vs UPDATE is a race condition: you can do the SELECT, someone else can then insert or delete, and then you attempt to do the wrong thing. To handle this correctly, you need an appropriat

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Jim Nasby
On 11/14/14, 10:09 AM, Adrian Klaver wrote: Trigger update_cpu_load_stat added to table trassa.cpu_load: CREATE TRIGGER update_cpu_load_stat_trigger AFTER INSERT ON trassa.cpu_load_stat FOR EACH ROW EXECUTE PROCEDURE trassa.update_cpu_load_stat(); Another run through showed that the

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Adrian Klaver
On 11/14/2014 07:32 AM, Brilliantov Kirill Vladimirovich wrote: Albe Laurenz wrote on 11/14/2014 01:28 PM: You should post the table definition and the whole trigger; the error message seems to refer to things you omitted in your quote. Yours, Laurenz Albe Turns out I was not at a suffic

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Adrian Klaver
On 11/14/2014 07:32 AM, Brilliantov Kirill Vladimirovich wrote: Albe Laurenz wrote on 11/14/2014 01:28 PM: You should post the table definition and the whole trigger; the error message seems to refer to things you omitted in your quote. Yours, Laurenz Albe Just approaching caffeine level r

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Brilliantov Kirill Vladimirovich
Albe Laurenz wrote on 11/14/2014 01:28 PM: You should post the table definition and the whole trigger; the error message seems to refer to things you omitted in your quote. Yours, Laurenz Albe Table with original data trassa.cpu_load: CREATE TABLE trassa.cpu_load ( id serial NOT NULL, de

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Adrian Klaver
On 11/14/2014 07:23 AM, Brilliantov Kirill Vladimirovich wrote: Adrian Klaver wrote on 11/14/2014 05:15 PM: Actually I think there is in the table the trigger is on. From the original post: SQL statement "INSERT INTO trassa.cpu_load (device, device_timestamp, cpu, value) VALUES(5,'1970-01-02 0

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Brilliantov Kirill Vladimirovich
Adrian Klaver wrote on 11/14/2014 05:15 PM: Actually I think there is in the table the trigger is on. From the original post: SQL statement "INSERT INTO trassa.cpu_load (device, device_timestamp, cpu, value) VALUES(5,'1970-01-02 06:02:38',0,6),(5,'1970-01-02 06:02:38',1,0),(5,'1970-01-02 06:02:

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Adrian Klaver
On 11/14/2014 03:24 AM, Albe Laurenz wrote: 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

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Albe Laurenz
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, >

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Brilliantov Kirill Vladimirovich
Albe Laurenz wrote on 11/14/2014 01:28 PM: 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 smallin

Re: [GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Albe Laurenz
Brilliantov Kirill Vladimirovich wrote: > I use Postgre-9.3.5 on windows7 x64. > I use simple trigger for store some statistic data, it code: > SELECT field IN variable FROM table WHERE ...; > IF FOUND THEN >UPDATE table SET field = ...; > ELSE >INSERT INTO table (field) VALUES(value); > EN

[GENERAL] NEW in after insert trugger contained incorrect data

2014-11-14 Thread Brilliantov Kirill Vladimirovich
Hello! I use Postgre-9.3.5 on windows7 x64. I use simple trigger for store some statistic data, it code: SELECT field IN variable FROM table WHERE ...; IF FOUND THEN UPDATE table SET field = ...; ELSE INSERT INTO table (field) VALUES(value); END IF; RETURN NULL; This trigger added as FOR EACH