From: | "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com> |
---|---|
To: | Berend Tober <btober(at)computer(dot)org> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Melvin Davidson <melvin6925(at)gmail(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Function PostgreSQL 9.2 |
Date: | 2016-05-05 09:04:18 |
Message-ID: | CAE_gQfULK3oxNh12EtaeQnhgyU+Y74Nj0f_sf7W72pAKvQx6HQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
>
>> SELECT client_code_increment INTO STRICT NEW.code FROM
>> public.companies WHERE id =
>> NEW.id ORDER BY client_code_increment DESC;
>>
>
>
>
> I am pretty sure the above line is wrong. NEW.id refers to users.id, not
> the companies.id. Also, the implementation presents a potential race
> condition, e.g., if two different sessions attempt an insert almost
> simultaneously.
I don't think so..
Even because if I change that to company_id, I get the error:
ERROR: column "company_id" does not exist
>
>
>
>
> END IF;
>> IF (TG_OP = 'INSERT') THEN
>> UPDATE public.companies SET client_code_increment =
>> (client_code_increment + 1) WHERE
>> id = NEW.id;
>>
>
>
> Ditto w.r.t. NEW.id.
>
>>
>>
Same as above
From | Date | Subject | |
---|---|---|---|
Next Message | Alban Hertroys | 2016-05-05 10:54:40 | Re: Function PostgreSQL 9.2 |
Previous Message | Berend Tober | 2016-05-05 07:40:57 | Re: Function PostgreSQL 9.2 |