Re: Function PostgreSQL 9.2
От | David G. Johnston |
---|---|
Тема | Re: Function PostgreSQL 9.2 |
Дата | |
Msg-id | CAKFQuwa-urBjWiPJJj8x+X9mb8ADMZe+ZbT7g45EzZmyt7Ygpg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Function PostgreSQL 9.2 (Alban Hertroys <haramrae@gmail.com>) |
Ответы |
Re: Function PostgreSQL 9.2
|
Список | pgsql-general |
> On 05 May 2016, at 8:42, drum.lucas@gmail.com wrote:
> The final function code is:
>
> CREATE OR REPLACE FUNCTION users_code_seq()
> RETURNS "trigger" AS $$
> DECLARE code character varying;
> BEGIN
> IF NEW.code IS NULL THEN
> SELECT client_code_increment INTO STRICT NEW.code FROM public.companies WHERE id = NEW.id ORDER BY client_code_increment DESC;
^^^^^^^
There's your problem. I'm pretty sure the keyword STRICT isn't valid there. It probably gets interpreted as a column name.
No, its a sanity check/assertion. If that trips its because there is no company having a value of NEW.id on the public.companies table. If that is OK then remove the STRICT but if you are indeed expecting a record to be present and it is not it is correctly telling you that there is a problem in the data. Namely that said company needs to be added to the table.
David J.
В списке pgsql-general по дате отправления: