Re: plpgsql: inserting a record into a (matching) table - Mailing list pgsql-novice

From Tom Lane
Subject Re: plpgsql: inserting a record into a (matching) table
Date
Msg-id 10280.1173823310@sss.pgh.pa.us
Whole thread Raw
In response to plpgsql: inserting a record into a (matching) table  (Brian Hurt <bhurt@janestcapital.com>)
List pgsql-novice
Brian Hurt <bhurt@janestcapital.com> writes:
> I'd like to do is something like (note that this does not work):

>     FOR t_rec IN
>         SELECT * from foo_table WHERE primary_key = old_key
>         t_rec.primary_key := new_key;
>         t_rec.other_column := new_value;
>         INSERT INTO foo_table VALUES ( t_rec ); -- Wrong- does not work

As of PG 8.2 I think that that will work if you say "t_rec.*" in the
VALUES.  As-is, it's asking the system to insert a composite datum into
the first column of the table.

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Error 25P02 - transaction aborted - Potential causes?
Next
From: Aly Dharshi
Date:
Subject: Re: [HACKERS] initdb fails - postgresql does not support leap seconds