From: ogjunk-pgjedan@yahoo.com
To: pgsql-sql@postgresql.org
Subject: copy old column's values to new column
Date: Thu, 2 Sep 2004 06:16:47 -0700 (PDT)
Message-ID: <20040902131647.26244.qmail@web12707.mail.yahoo.com> (raw)
Hello,
I need some basic SQL help. I added a new column to an existing table,
and now I need to copy values from one of the old columns to this new
columns.
I need something like this:
FOR pvId IN SELECT id FROM preference_value LOOP
update preference_value SET display_value = (select value from
preference_value where id=pvId) where id=pvId;
END LOOP;
I tried running this from psql, but it didn't work (I suspect FOR can
be used in functions, which I don't know how to write in PG, yet).
Is there a simple way to do this?
Thanks,
Otis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ogjunk-pgjedan@yahoo.com
Subject: Re: copy old column's values to new column
In-Reply-To: <20040902131647.26244.qmail@web12707.mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox