Re: Combining scalar and row types in RETURNING

Поиск
Список
Период
Сортировка
От PetSerAl
Тема Re: Combining scalar and row types in RETURNING
Дата
Msg-id CAKygsHSmiDzcXSruEjR2XSbyF9WP2Ro3ni5utWS+XAGScJd8EQ@mail.gmail.com
обсуждение исходный текст
Список 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



В списке pgsql-general по дате отправления: