Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Marc G. Fournier
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

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Tom Lane
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 ab

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Andrew Dunstan
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

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Tom Lane
"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 functi

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Marc G. Fournier
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

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-08-30 Thread Greg Stark
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 field1<>0" Odd that everyone did a CASE for that. -- greg ---(end of broadcast)--

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-08-29 Thread Tom Lane
"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 bool

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-08-29 Thread Rod Taylor
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

Re: [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-08-29 Thread David Fetter
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 > ---

[HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-08-29 Thread Marc G. Fournier
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: #