Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYtTJ-00ErhR-48 for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 20:29:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sYtTH-00DMSR-27 for pgsql-general@arkaria.postgresql.org; Tue, 30 Jul 2024 20:29:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYtTG-00DMSJ-Mq for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 20:29:22 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sYtT9-002JYM-VL for pgsql-general@lists.postgresql.org; Tue, 30 Jul 2024 20:29:22 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5d5b1e33fa8so2727610eaf.3 for ; Tue, 30 Jul 2024 13:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722371353; x=1722976153; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=o7Vg7e1oe+n5b+PjWB+tj5yDe4towKzGQzBYtokRMbA=; b=Q7FxUPtaO/21kPHJ6/BY2NzppcQ/mfJdAyXxN1nQ6Fr56Cs/c6a2k5v9q1a2OjFW2m WyFlyOBsYVDEl8G5jT8JH3PDNjbGOx1vxIMqqN4bmX519SdlCju5BMI7ZR+ZbQBB3jtE 4kziHrLlPrhS2UD/DoZFgTKTXDPs4cZruFGXyEL4IKjD12HJJjWJZAI81Me9uAo69n+9 d3DYRHW5hW8sP7X3aR/+0hz0J1hcyyu/kwPeKByrYAfgIsemuiheqN0jJUC4/4LXYskJ LagjZP6ZgkfnqtHu//qyVPOU0Urq+6AskBXzgi7cL0CkY4aJC8S/gWmmh57cLVuNqnUA miyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722371353; x=1722976153; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=o7Vg7e1oe+n5b+PjWB+tj5yDe4towKzGQzBYtokRMbA=; b=PBpfA96Fjplv2wP0mcMMxZgoqNSUMphW9Ra/oR2egdZ9tlUxxL0+stn9ZwHEIu0TN0 nzFroUgFp1ZiUMj+e0oBGQFYjBYaTyaSvOONb9ct37VmkavrwiGirL5Wblm1SCQDIuTM 0dhJ8nUjsInQ+jLdBuTn8M2ASrnpwDEl5wk/JRIay2hKcIUb98urOHpcb1vlxkDitBFP tlqchbFYeJsiTsOMST3p/FfZXcHkEZpboML8pM3MgfHuXahF1FWHubQvCgEWBaKUYhvC cw3hV9isJU7YP6/xW4ClsEKfMlbjTRZ1BHRTukv/RsE+d6TECraMySrJY698jEXvAiEq jSDw== X-Forwarded-Encrypted: i=1; AJvYcCWDHGJhru+dhdVVX3AG7uPkABuIK67mMpZsdx6x+pn9Npe10JTM32kCJuldztrtkTeTRtI65VAx4h8NxPyu/kqydglA5SuUa++hSIIbB3n+ZkSO X-Gm-Message-State: AOJu0YzOoLCb5B9A7veNX6kP5IXlmo+YnJw9NFKpSorYZnAyXfyjv5gG iGjsJr2Gj3t3X+4DgRyTUL7Li9xipLIa2I+4NSvaTSzQElaQDibdnDGwqrn9QsggYi3MRdwWqgg Whpd28cc6DqUxs95wL7L2NBbwxa8= X-Google-Smtp-Source: AGHT+IEu/m+vSidqMEQEQh8bmW9mMmEZKUWOSnm0NGEqf6F2uUyU+P6IpByVfw8lMIeMBAOdXpPkLvPuKo7+itWvzJA= X-Received: by 2002:a05:6820:1ca2:b0:5c6:5f2d:8430 with SMTP id 006d021491bc7-5d5d0d8c704mr14216053eaf.2.1722371353441; Tue, 30 Jul 2024 13:29:13 -0700 (PDT) MIME-Version: 1.0 References: <85cc2eb0ca709ab753e618584f46dbf8801e9658.camel@cybertec.at> In-Reply-To: From: "David G. Johnston" Date: Tue, 30 Jul 2024 13:28:35 -0700 Message-ID: Subject: Re: Trigger usecase To: sud Cc: Laurenz Albe , pgsql-general Content-Type: multipart/alternative; boundary="000000000000b17f07061e7cd4e1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b17f07061e7cd4e1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jul 30, 2024 at 11:46=E2=80=AFAM sud wrote: > > 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 throu= gh > database procedure/functions. Hope this understanding correct. > That is my personal take. For process-oriented stuff you can follow the trail of calls all the way through to the end of the process and its final result. With triggers you follow the trail to the insert/update/delete then stop thinking that's it, while in reality it continues because you have triggers performing yet more work. David J. --000000000000b17f07061e7cd4e1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Jul 30, 2024 at 11:46=E2=80=AFAM sud <suds1434@gmail.com> wrote:
=

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

That is my persona= l take.=C2=A0 For process-oriented stuff you can follow the trail of calls = all the way through to the end of the process and its final result.=C2=A0 W= ith triggers you follow the trail to the insert/update/delete then stop thi= nking that's it, while in reality it continues because you have trigger= s performing yet more work.

David J.

--000000000000b17f07061e7cd4e1--