Thread: Re: Combining scalar and row types in RETURNING

Re: Combining scalar and row types in RETURNING

From
PetSerAl
Date:
> 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