How to convert integer to boolean in insert

From: JiangMiao <jiangfriend(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to convert integer to boolean in insert
Date: 2009-04-05 11:14:37
Message-ID: 0a4b02a4-fb38-456e-8c64-e76d2f8434d4@d19g2000prh.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

for table
foo
banned:boolean

When try run 'insert into foo(banned) values(0)'
It returns
ERROR: column "banned" is of type boolean but expression is of type
integer
LINE 1: insert into foo(banned) values(0)

and I found a way to add the cast
insert into foo(banned) values(0::boolean)
but I have a big table which dump from mysqldump and covert by
mysql2pgsql. all of boolean relation values is 0 instead of '0' or
FALSE.

Is there any way to make pgsql implicit cast the integer to boolean?

Thanks
--
Miao

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2009-04-05 12:19:14 Re: How to convert integer to boolean in insert
Previous Message Eduardo Henrique 2009-04-04 21:36:33 Postgres Security Checklist