Re: Trigger usecase

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: sud <suds1434(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Trigger usecase
Date: 2024-07-30 18:50:48
Message-ID: 08b3b796-3165-4104-a250-b1c6387cf98d@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/30/24 11:46, sud wrote:
>
> On Tue, Jul 30, 2024 at 10:54 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at
> <mailto:laurenz(dot)albe(at)cybertec(dot)at>> 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.

Triggers have to use procedures/functions so I am not understanding the
issue.

>
> Regards
> Sud

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2024-07-30 20:28:35 Re: Trigger usecase
Previous Message sud 2024-07-30 18:46:01 Re: Trigger usecase