pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Dynamically accessing columns from a row type in a trigger
Date: Mon, 14 Aug 2023 18:49:14 -0600
Message-ID: <4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@gmail.com> (raw)
In-Reply-To: <CACg0vT=ELyfN5NEdp001TkJQxKyoxAAyUPwMmY_d+xYBHYMRtg@mail.gmail.com>
References: <CACg0vTm8in3pdagru2Y-Q5Ru8UqfgVaqfTiW+kRw0jAj2wWQkw@mail.gmail.com>
	<068f5479-5b58-6084-1141-fd320b722782@aklaver.com>
	<CACg0vTkrqqnuNrHN2iNgQdAdB5JiVJthj31M1OHYSeeZwMpWXw@mail.gmail.com>
	<CACJufxHVWB+0-qZOwryOZ4Usx2N5u68JMKxsqjCfzK-3ud=FCg@mail.gmail.com>
	<CACg0vT=ELyfN5NEdp001TkJQxKyoxAAyUPwMmY_d+xYBHYMRtg@mail.gmail.com>

So the less obvious solution that works is to create a temporary
> table. A little verbose, but I get to keep the types.
>
> `CREATE TEMPORARY TABLE _ ON COMMIT DROP AS SELECT OLD.*;`
>
> _ as a table name makes things a little easier to type.
>
>
>
> Rhys
> Peace & Love | Live Long & Prosper
>
>
If the connection creating the table is long-lived, maybe make the table 
once and truncate instead.







view thread (10+ messages)  latest in thread

Message-ID: <4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@gmail.com>
Permalink:  ../4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@gmail.com/
Also on:    postgresql.org/message-id/4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@gmail.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: robjsargent@gmail.com
  Subject: Re: Dynamically accessing columns from a row type in a trigger
  In-Reply-To: <4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@gmail.com>
  References: <CACg0vTm8in3pdagru2Y-Q5Ru8UqfgVaqfTiW+kRw0jAj2wWQkw@mail.gmail.com> <068f5479-5b58-6084-1141-fd320b722782@aklaver.com> <CACg0vTkrqqnuNrHN2iNgQdAdB5JiVJthj31M1OHYSeeZwMpWXw@mail.gmail.com> <CACJufxHVWB+0-qZOwryOZ4Usx2N5u68JMKxsqjCfzK-3ud=FCg@mail.gmail.com> <CACg0vT=ELyfN5NEdp001TkJQxKyoxAAyUPwMmY_d+xYBHYMRtg@mail.gmail.com> <4c1e0917-4ee8-6a10-f06b-dae47bd05ae7@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox