From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Shah <ashah@opuspro.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Query for block updates
Date: Sun, 03 Dec 2006 17:22:49 -0500
Message-ID: <24732.1165184569@sss.pgh.pa.us> (raw)
In-Reply-To: <200612031719.44642.ashah@opuspro.com>
References: <200612031719.44642.ashah@opuspro.com>
Amit Shah <ashah@opuspro.com> writes:
> I am using this query - alter table optiondata ALTER volume TYPE numeric(20,4)
> using cast(volume as numeric(20,4)); then wait for DB to complain, and then
> update that value to null, and just keep doing this till all garbadge is
> removed :-(
You could automate it in plpgsql ... something like
for r in select id, val from table
loop
begin
perform cast(r.val as numeric(20,4));
exception
when ... then
update table set val = null where id = r.id;
end;
end loop;
and then do the ALTER TYPE after you've cleaned the data.
regards, tom lane
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: tgl@sss.pgh.pa.us, ashah@opuspro.com
Subject: Re: Query for block updates
In-Reply-To: <24732.1165184569@sss.pgh.pa.us>
* 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