Re: casting from integer to boolean

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: Seb <spluque(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: casting from integer to boolean
Date: 2008-03-26 22:46:47
Message-ID: 396486430803261546v501d2cb5p1a5c756c786c511a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 26, 2008 at 3:28 PM, Seb <spluque(at)gmail(dot)com> wrote:

> On Wed, 26 Mar 2008 15:11:47 -0700,
> "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com> wrote:
>
> [...]
>
> > INSERT INTO my_table (var_bool) VALUES ( CAST( 0 AS BOOLEAN )); or
> > INSERT INTO my_table (var_bool) VALUES (0::BOOLEAN);
>
>
> Thanks Richard. Is there a way to do it without changing the INSERT
> command? As I mentioned, there are many more columns of different
> types, so finding and replacing the VALUES would be very difficult.

My understanding is that a temporary staging table could be used to receive
all of your data into postgresql. Next, you can perform most of your data
scrubbing within postgres with simple update statements.
Last, you and insert to the cleaned data with an insert+select statement
with the appropriate casts. this way you only need to do the casting in a
single statement.

--
Regards,
Richard Broersma Jr.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Seb 2008-03-26 22:54:25 Re: casting from integer to boolean
Previous Message Sam Mason 2008-03-26 22:46:08 Re: casting from integer to boolean