Re: Function PostgreSQL 9.2

From: Lucas Possamai <drum(dot)lucas(at)gmail(dot)com>
To: Berend Tober <btober(at)computer(dot)org>
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-23 21:40:15
Message-ID: CAE_gQfUdGG1bYBe+qB7=hpFQn9QJZ_7N97-6z5DK7iLeQ+a=gA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just an update here:

IF (TG_OP = 'INSERT') THEN
> UPDATE public.companies SET client_code_increment =
> (client_code_increment + 1) WHERE id = NEW.company_id;

The line above was updating the client_code_increment even if the customer
was inserting data by hiimself, which is wrong.
The client_code_increment must be updated IF is an insert AND if the
customer did not insert data into the code column.

*Correction:*

IF (TG_OP = 'INSERT') AND NEW.code IS NULL THEN
> UPDATE public.companies SET client_code_increment =
> (client_code_increment + 1) WHERE id = NEW.company_id;

Cheers
Lucas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2016-05-23 21:40:51 Re: Increased I/O / Writes
Previous Message Lucas Possamai 2016-05-23 21:37:43 Re: index on ILIKE/LIKE - PostgreSQL 9.2