casting from integer to boolean

From: Seb <spluque(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: casting from integer to boolean
Date: 2008-03-26 21:58:27
Message-ID: 87ej9xqha4.fsf@patagonia.sebmags.homelinux.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 mdb-export. The problem is that the boolean
fields are exported as integers (0, 1), i.e. the INSERT commands for the
booleans look like:

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 0s and
1s with their quoted versions. Is there any way to make such INSERT
commands be valid? I have no experience with CAST, so any pointers
would be welcome. Thanks.

Cheers,

--
Seb

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma 2008-03-26 22:11:47 Re: casting from integer to boolean
Previous Message Joshua D. Drake 2008-03-26 21:34:53 East: Online Registration closes at 5:00pm PST