On Mon, 29 Aug 2005, Tom Lane wrote:
Marc G. Fournier [EMAIL PROTECTED] writes:
# ALTER TABLE table ALTER COLUMN field1 type boolean;
ERROR: column field1 cannot be cast to type pg_catalog.bool
Should this not work?
No, because there's no built-in cast from smallint to bool. You could
Marc G. Fournier [EMAIL PROTECTED] writes:
On Mon, 29 Aug 2005, Tom Lane wrote:
No, because there's no built-in cast from smallint to bool.
'k, I just took a read through the CREATE CAST man page, and don't think
I can use that for this,
Sure you can. Make a SQL or PLPGSQL function that
Tom Lane wrote:
Marc G. Fournier [EMAIL PROTECTED] writes:
On Mon, 29 Aug 2005, Tom Lane wrote:
No, because there's no built-in cast from smallint to bool.
'k, I just took a read through the CREATE CAST man page, and don't think
I can use that for this,
Sure you
Andrew Dunstan [EMAIL PROTECTED] writes:
Tom Lane wrote:
Sure you can. Make a SQL or PLPGSQL function that does the conversion
you want and then create a cast using it.
That probably won't help him much with values(0):
If I remember the context of the original request, it wasn't about that
On Thu, 1 Sep 2005, Tom Lane wrote:
Andrew Dunstan [EMAIL PROTECTED] writes:
Tom Lane wrote:
Sure you can. Make a SQL or PLPGSQL function that does the conversion
you want and then create a cast using it.
That probably won't help him much with values(0):
If I remember the context of the
Tom Lane [EMAIL PROTECTED] writes:
You could do something like
... type boolean using case when field1=0 then false else true end;
Or you could save typing and just use USING field10
Odd that everyone did a CASE for that.
--
greg
---(end of
I have a table with several 'smallint' fields that I'd like to convert to
booleean ... the data in each is either 0 or 1, and:
# select '1'::boolean;
bool
--
t
(1 row)
# select '0'::boolean;
bool
--
f
(1 row)
so they do cast as expected ... but, if I try to do the ALTER, I get:
On Mon, Aug 29, 2005 at 08:15:41PM -0300, Marc G. Fournier wrote:
I have a table with several 'smallint' fields that I'd like to convert to
booleean ... the data in each is either 0 or 1, and:
# select '1'::boolean;
bool
--
t
(1 row)
# select '0'::boolean;
bool
--
f
(1
On Mon, 2005-08-29 at 20:15 -0300, Marc G. Fournier wrote:
I have a table with several 'smallint' fields that I'd like to convert to
booleean ... the data in each is either 0 or 1, and:
# ALTER TABLE table ALTER COLUMN field1 type boolean;
ERROR: column field1 cannot be cast to type
Marc G. Fournier [EMAIL PROTECTED] writes:
# ALTER TABLE table ALTER COLUMN field1 type boolean;
ERROR: column field1 cannot be cast to type pg_catalog.bool
Should this not work?
No, because there's no built-in cast from smallint to bool. You could
do something like
... type boolean using
10 matches
Mail list logo