Search Postgresql Archives

Re: Function PostgreSQL 9.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> On 05 May 2016, at 8:42, drum.lucas@xxxxxxxxx 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.

>         END IF;
>         IF (TG_OP = 'INSERT') THEN
>         UPDATE public.companies SET client_code_increment = (client_code_increment + 1) WHERE id = NEW.id;
>         END IF;
>         RETURN NEW;
> END;
> $$ LANGUAGE plpgsql;

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux