public inbox for [email protected]  
help / color / mirror / Atom feed
From: sud <[email protected]>
To: Laurenz Albe <[email protected]>
To: David G. Johnston <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Trigger usecase
Date: Wed, 31 Jul 2024 00:16:01 +0530
Message-ID: <CAD=mzVVOC=H9zhYn5YF74XMV+7023f5hPvcroSaQu61m7q-yCg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAD=mzVU0rx4A0onfC4jHxZ7XreZrk9DNa9pFoGDOjPD1ZhfHgw@mail.gmail.com>
	<[email protected]>

On Tue, Jul 30, 2024 at 10:54 PM Laurenz Albe <[email protected]>
wrote:

>
> It is largely a matter of taste.
>
> The advantage of a trigger is that it works even if somebody bypasses the
> application
> to insert data.
>
> I think that triggers are easy to debug, but again, that's a matter of
> taste.
>
>
> Thank you David and Laurenz.

Creating triggers to populates some audit table or say populating data in
audit columns (created_by, updated_by,created_date,updated_date) is fine i
believe, however this use case was to load/persist data in table with SCD-2
style, so is it good idea to use the trigger for such use case?

Not sure of the exact pros and cons, but we were following certain rules
like , if it's business logic which needs to be implemented in Database,
then it should not be done using triggers but rather should be done through
database procedure/functions. Hope this understanding correct.

Regards
Sud


view thread (4+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Trigger usecase
  In-Reply-To: <CAD=mzVVOC=H9zhYn5YF74XMV+7023f5hPvcroSaQu61m7q-yCg@mail.gmail.com>

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

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