Re: Trigger

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Alban Hertroys <haramrae(at)gmail(dot)com>
Cc: Sonam Sharma <sonams1209(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger
Date: 2020-02-25 17:13:04
Message-ID: 36dbe912-6596-1eff-d270-42f356d042f0@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/25/20 9:08 AM, Alban Hertroys wrote:
>
>> On 25 Feb 2020, at 17:53, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> wrote:
>>
>> On 2/25/20 12:01 AM, Sonam Sharma wrote:
>>> I have a trigger, like many other triggers that fire after
>>> update and checks a field of the OLD set. For some reason this trigger throw this error:
>>> ERROR: record "old" has no field "ivo_sts_cd" CONTEXT: SQL statement
>>
>>> if exc_count = 0 then
>>> UPDATE pps.T8071_CAI_IVO_HDR SET IVO_STS_CD = 1 where T616_VBU_NBR=old.T616_VBU_NBR and T617_FNC_TYP_CD=old.T617_FNC_TYP_CD and
>>> T8071_CAI_IVO_ID=old.T8071_CAI_IVO_ID and T8071_ADD_DM= old. T8071_ADD_DM and old.ivo_sts_cd != 10 and old.ivo_sts_cd != 3;
>>
>> Realized I went through the above to quickly. I do not see a SET, nor am I clear what table you are trying to UPDATE.
>
> I’m pretty sure that if the OP were to format their query in a more readable and consistent way, they would spot their error pretty quickly. It’s a simple typo.

Yeah, throwing it at:

http://sqlformat.darold.net/

returned:

UPDATE
pps.T8071_CAI_IVO_HDR
SET
IVO_STS_CD = 1
WHERE
T616_VBU_NBR = old.T616_VBU_NBR
AND T617_FNC_TYP_CD = old.T617_FNC_TYP_CD
AND T8071_CAI_IVO_ID = old.T8071_CAI_IVO_ID
AND T8071_ADD_DM = old. T8071_ADD_DM
AND old.ivo_sts_cd != 10
AND old.ivo_sts_cd != 3;

Found the SET:)

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

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

  • Re: Trigger at 2020-02-25 17:08:27 from Alban Hertroys

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2020-02-25 17:20:34 Re: Connections dropping while using Postgres backend DB with Ejabberd
Previous Message Alban Hertroys 2020-02-25 17:08:27 Re: Trigger