Re: Combining scalar and row types in RETURNING

From: PetSerAl <petseral(at)gmail(dot)com>
To: "Ray O'Donnell" <ray(at)rodonnell(dot)ie>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Combining scalar and row types in RETURNING
Date: 2025-06-05 17:09:21
Message-ID: CAKygsHSmiDzcXSruEjR2XSbyF9WP2Ro3ni5utWS+XAGScJd8EQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> In my case, m_new_data is actually a table row type rather than plain
> "record". The row is passed on to another function which calculates the
> altered columns and logs the changes.

In my experience, to specify composite-typed receiver as one element
of INTO list, it need to be column of composite variable.

CREATE TABLE t (a int, b int, c int);
CREATE TYPE wrap AS (v t);
DO $DO$
DECLARE
s text;
w wrap;
BEGIN
INSERT INTO t VALUES (1, 2, 3)
RETURNING 'text', t
INTO s, w.v;
RAISE '%, %', s, w.v;
END;
$DO$;

https://dbfiddle.uk/e5Q4Fj6l

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2025-06-05 20:57:24 Re: LOCALE C.UTF-8 on EDB Windows v17 server
Previous Message Dominique Devienne 2025-06-05 15:40:04 Re: LOCALE C.UTF-8 on EDB Windows v17 server