Re: plperl trigger problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Christian Maier" <tomtailor(at)freesurf(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: plperl trigger problem
Date: 2006-12-20 14:44:02
Message-ID: 21313.1166625842@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Christian Maier" <tomtailor(at)freesurf(dot)fr> writes:
> I have some csv data and some columns are in a bad format. this means
> that some float values are formatet as " ." if the are 0. So I have
> made an before insert trigger that looks for these values and replaces
> them but it dont work and I cannot found the mistake.

The mistake is that you're imagining that the trigger runs before the
data is converted to internal format. You can't really fix it this way.

What I'd suggest is loading the cvs file into a temp table in which the
bogus column is declared as text rather than float8. Then you can do
the data correction as a simple UPDATE on that table, and finally load
the data into the real table with INSERT/SELECT.

Alternatively, fix the file with a perl or sed script before you load it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2006-12-20 14:52:47 Re: windows - silent uninstall question
Previous Message Alvaro Herrera 2006-12-20 14:33:29 Re: out of memory woes