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

Re: plpgsql question: inserting records

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brian Hurt <bhurt(at)janestcapital(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: plpgsql question: inserting records
Date: 2007-10-26 19:16:29
Message-ID: 24837.1193426189@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Brian Hurt <bhurt(at)janestcapital(dot)com> writes:
> There has to be an easy way to do this and I'm just being stupid and 
> missing it.  What I want to do is, in plpgsql, insert a record (of the 
> right type) into a table without having to list all the columns of the 
> table.  For example, I'd like to do:

Some experimentation says that "VALUES(t_rec.*)" will work as long as
t_rec is declared as the table's rowtype, and not generic "record".
(I didn't try it further back than 8.1 though.)

For future-proofing purposes I'd advise spelling it with extra
parentheses: VALUES((t_rec).*).  It doesn't matter right now but
might someday.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Mija LeeDate: 2007-10-26 19:56:11
Subject: thread by Jessica Richards on read only permissions
Previous:From: G. J. WalshDate: 2007-10-26 18:59:34
Subject: Re: readline library not found

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