pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Sonam Sharma <sonams1209@gmail.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Trigger
Date: Tue, 25 Feb 2020 08:14:59 -0800
Message-ID: <17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com> (raw)
In-Reply-To: <CAM-M3TkOWhUsWPtgDhaNbrNTKeHXX2mykxHaEbM_ZSQe+ozZdA@mail.gmail.com>
References: <CAM-M3TkOWhUsWPtgDhaNbrNTKeHXX2mykxHaEbM_ZSQe+ozZdA@mail.gmail.com>

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
> 
> "UPDATE dbo.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" PL/pgSQL
> 
> function dbo.t8096_upd_func02() line 9 at SQL statement SQL state: 42703
> 
> this is the trigger :
> 
> t8096_upd_trig02 AFTER UPDATE ON dbo.t8096_cai_ivo_exc FOR EACH ROW WHEN 
> (old.exc_rsd_idc IS DISTINCT FROM new.exc_rsd_idc) EXECUTE PROCEDURE 
> dbo.t8096_upd_func02()
> 
> below is the function :
> 
> CREATE OR REPLACE FUNCTION pps.t8096_upd_func02()
> 
> RETURNS trigger
> 
> LANGUAGE plpgsql
> 
> AS $function$
> 
> DECLARE
> 
> exc_count int;
> 
> BEGIN
> 
> select count(*) into exc_count from pps.T8096_CAI_IVO_EXC 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 EXC_RSd_IDC = 'N'
> 
> AND T8095_EXC_TYP_CD NOT IN(8,9,10,11) ;
> 
> 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;
> 
> end if;
> 
> RETURN NEW;
> 
> END
> 
> $function$;
> 
> 
> Can someone please help where I am missing ..

Does the table dbo.t8096_cai_ivo_exc have the field ivo_sts_cd?

> 
> 
> Thanks,
> 
> Sonam
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (47+ messages)  latest in thread

Message-ID: <17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com>
Permalink:  ../17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com/
Also on:    postgresql.org/message-id/17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, sonams1209@gmail.com
  Subject: Re: Trigger
  In-Reply-To: <17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com>
  References: <CAM-M3TkOWhUsWPtgDhaNbrNTKeHXX2mykxHaEbM_ZSQe+ozZdA@mail.gmail.com> <17412b0b-d594-a96f-e93c-21ef638b7726@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox