drum.lu...@gmail.com wrote:
It's working now...

Final code:

    ALTER TABLE public.companies ADD COLUMN client_code_increment integer;
    ALTER TABLE public.companies ALTER COLUMN client_code_increment SET NOT 
NULL;
    ALTER TABLE public.companies ALTER COLUMN client_code_increment SET DEFAULT 
1000;
    COMMIT TRANSACTION;

    BEGIN;
    -- Creating the function
    CREATE OR REPLACE FUNCTION users_code_seq()
        RETURNS "trigger" AS $$
    DECLARE code character varying;
    BEGIN
    -- if it's an insert, then we update the client_code_increment column value 
to +1
             IF (TG_OP = 'INSERT') THEN  ...


Think about it, will (TG_OP = 'INSERT') ever be untrue.






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

Reply via email to