Re: Function PostgreSQL 9.2 - Mailing list pgsql-general

From Berend Tober
Subject Re: Function PostgreSQL 9.2
Date
Msg-id 572C8398.8080708@computer.org
Whole thread Raw
In response to Re: Function PostgreSQL 9.2  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
Responses Re: Function PostgreSQL 9.2
List pgsql-general
drum.lucas@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.






pgsql-general by date:

Previous
From: Kurt Roeckx
Date:
Subject: Re: Very slow update / hash join
Next
From: Adrian Klaver
Date:
Subject: Re: Debian and Postgres