From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Amit Shah <ashah(at)opuspro(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Query for block updates |
Date: | 2006-12-03 22:22:49 |
Message-ID: | 24732.1165184569@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Amit Shah <ashah(at)opuspro(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Schaber | 2006-12-04 10:56:32 | Re: pg_xlog on separate drive |
Previous Message | Amit Shah | 2006-12-03 22:19:44 | Query for block updates |