Re: cast bool/int

From: Zdravko Balorda <zdravko(dot)balorda(at)siix(dot)com>
To: Joshua Tolley <eggyknap(at)gmail(dot)com>
Cc: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: cast bool/int
Date: 2009-03-23 14:45:04
Message-ID: 49C7A070.6070600@siix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


>> CASE WHEN column='t' THEN 1 ELSE 0 END
>
> Or just CASE WHEN column THEN 1 ELSE 0 END.

In the mean time I've got an elegant solution:

alter ... ... column TYPE smallint USING column::boolean::int::smallint;

It works, you wouldn't beleive it. ;)
Zdravko

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message DM 2009-03-23 15:04:14 Re: pg_restore error - Any Idea?
Previous Message Marcin Krawczyk 2009-03-23 14:44:31 Re: cast bool/int