Re: Inserting Using RowType

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Inserting Using RowType
Дата
Msg-id 24344.1114623363@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Inserting Using RowType  (Greg Lindstrom <greg.lindstrom@novasyshealth.com>)
Список pgsql-novice
Greg Lindstrom <greg.lindstrom@novasyshealth.com> writes:
> What I would then like to do is:

> INSERT INTO my_table ib837;

The trick is to get it to "burst" the rowtype value into separate columns.
I don't think you could get it to do that before 8.0, but this works
as of 8.0:

regression=# \d int8_tbl
   Table "public.int8_tbl"
 Column |  Type  | Modifiers
--------+--------+-----------
 q1     | bigint |
 q2     | bigint |

regression=# create function foo(bigint,bigint) returns void as $$
regression$# declare myrow int8_tbl;
regression$# begin
regression$#   myrow.q1 = $1;
regression$#   myrow.q2 = $2;
regression$#   insert into int8_tbl select (x).* from (select myrow as x) ss;
regression$#   return;
regression$# end$$ language plpgsql;
CREATE FUNCTION

            regards, tom lane

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

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: Inserting Using RowType
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Inserting Using RowType