Re: Inserting Using RowType - Mailing list pgsql-novice

From Tom Lane
Subject Re: Inserting Using RowType
Date
Msg-id 24344.1114623363@sss.pgh.pa.us
Whole thread Raw
In response to Inserting Using RowType  (Greg Lindstrom <greg.lindstrom@novasyshealth.com>)
List 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 by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Inserting Using RowType
Next
From: Tom Lane
Date:
Subject: Re: Inserting Using RowType