Re: Function PostgreSQL 9.2

From: Berend Tober <btober(at)computer(dot)org>
To: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Alban Hertroys <haramrae(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-06 11:44:24
Message-ID: 572C8398.8080708@computer.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

drum(dot)lucas(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-05-06 13:42:22 Re: Debian and Postgres
Previous Message Kurt Roeckx 2016-05-06 10:21:04 Re: Very slow update / hash join