Re: [GENERAL] casting from integer to boolean

2008-03-27 Thread Seb
On Wed, 26 Mar 2008 18:03:06 -0500, Seb <[EMAIL PROTECTED]> wrote: > On Wed, 26 Mar 2008 22:46:08 +, > Sam Mason <[EMAIL PROTECTED]> wrote: [...] >> You could turn the problem around and make the bool columns into ints >> (which should be a simple search-and-replace, I hope) and then write >

Re: [GENERAL] casting from integer to boolean

2008-03-27 Thread Richard Broersma
On Thu, Mar 27, 2008 at 12:40 AM, Martijn van Oosterhout <[EMAIL PROTECTED]> wrote: > Don't think anyone mentioned it, but if you could get it to output > quotes around the value, like: > > INSERT INTO my_table (var_bool) VALUES ('0'); > > It will also work. > This is good to know. There is an o

Re: [GENERAL] casting from integer to boolean

2008-03-27 Thread Martijn van Oosterhout
On Wed, Mar 26, 2008 at 05:28:18PM -0500, Seb 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 m

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Seb
On Wed, 26 Mar 2008 22:46:08 +, Sam Mason <[EMAIL PROTECTED]> wrote: [...] > You could turn the problem around and make the bool columns into ints > (which should be a simple search-and-replace, I hope) and then write > something (again hopefully simple) to turn them all back into bools. > I.

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Tom Lane
"Adam Rich" <[EMAIL PROTECTED]> writes: >> 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. > Can you import the data into a holding tabl

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Richard Broersma
On Wed, Mar 26, 2008 at 3:28 PM, Seb <[EMAIL PROTECTED]> wrote: > On Wed, 26 Mar 2008 15:11:47 -0700, > "Richard Broersma" <[EMAIL PROTECTED]> wrote: > > [...] > > > INSERT INTO my_table (var_bool) VALUES ( CAST( 0 AS BOOLEAN )); or > > INSERT INTO my_table (var_bool) VALUES (0::BOOLEAN); > > > Th

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Seb
On Wed, 26 Mar 2008 17:34:59 -0500, "Adam Rich" <[EMAIL PROTECTED]> wrote: [...] > Can you import the data into a holding table (with columns defined as > integer) first, and then use a SQL statement to insert from there into > the final destination table (casting in the process) ? Yes, that wou

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Sam Mason
On Wed, Mar 26, 2008 at 05:28:18PM -0500, Seb wrote: > On Wed, 26 Mar 2008 15:11:47 -0700, > "Richard Broersma" <[EMAIL PROTECTED]> wrote: > > [...] > > > INSERT INTO my_table (var_bool) VALUES ( CAST( 0 AS BOOLEAN )); or > > INSERT INTO my_table (var_bool) VALUES (0::BOOLEAN); > > > Thanks Ric

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Adam Rich
> 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. Can you import the data into a holding table (with columns defined as integer) first, an

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Seb
On Wed, 26 Mar 2008 15:11:47 -0700, "Richard Broersma" <[EMAIL PROTECTED]> 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

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Richard Broersma
On Wed, Mar 26, 2008 at 2:58 PM, Seb <[EMAIL PROTECTED]> wrote: > INSERT INTO my_table (var_bool) VALUES (0); > INSERT INTO my_table (var_bool) VALUES (1); > > So this results in an error. Unfortunately, there are many more columns > and it would be very difficult to write a regexp to replace the

[GENERAL] casting from integer to boolean

2008-03-26 Thread Seb
Hi, I'm running into a problem importing some MS Access tables into PostgreSQL using mdbtools. The schema is exported effectively with mdb-schema, but several tables have boolean columns. To deal with some embedded double quotes in text fields, I'm exporting the tables as INSERT commands using m