Skip site navigation (1) Skip section navigation (2)

Re: Inserting Using RowType

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Lindstrom <greg(dot)lindstrom(at)novasyshealth(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Inserting Using RowType
Date: 2005-04-27 17:36:03
Message-ID: (view raw or flat)
Lists: pgsql-novice
Greg Lindstrom <greg(dot)lindstrom(at)novasyshealth(dot)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;

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2005-04-27 18:08:33
Subject: Re: Inserting Using RowType
Previous:From: Michael FuhrDate: 2005-04-27 17:34:16
Subject: Re: Inserting Using RowType

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group