Doh! I suck, I had a CHECK constraint on that column to make sure the
value was between 0 and 4 (the whole reason I was switching to an
enum). Once I dropped the constraint, the ALTER TABLE worked
perfectly.
I guess I have to gripe about the error message though, it should tell
me there was a pr
Ok, I'm convinced this should work but it does not:
CREATE FUNCTION ConvertIntToOrderStateEnum(state integer) RETURNS
OrderStateEnum AS
$BODY$
SELECT CASE WHEN $1=0 then 'Preview'::OrderStateEnum
WHEN $1=1 then 'InQueue'::OrderStateEnum
WHEN $1=2 then 'Ordered'::OrderStateEnum
WHEN $1=3 t
Hi all -
I have an existing table that looks like this:
CREATE TABLE orders
(
--Bunch of stuff you don't care about
orderstate integer NOT NULL,
--Etc
)
with a bunch of data in it. I've now created this new data type:
CREATE TYPE OrderStateEnum AS ENUM ('Preview', 'InQueue', 'Ordered',
'