title: PostgreSQL: changing a column of enum type
body: <p>This is the definition of the enumerated type:  </p>
  
  <pre><code>CREATE TYPE khstate AS ENUM ('none', 'form', 'test', 'finished');
  </code></pre>
  
  <p>Now, in a database table I have a row with columns 'id' (type SERIAL) and 'state' (type khstate). The value of the 'id' column is 100004, and the value of the 'state' column is 'none'. How do I change it to, say, 'form'? The table definition is as follows.</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS khs (  
      id SERIAL UNIQUE,  
      state khstate DEFAULT 'none',  
      PRIMARY KEY (id)  
  );
  </code></pre>
  
  <p>I have tried queries such as</p>
  
  <pre><code>UPDATE tablename SET state = 'form' WHERE id = 100004;  
  </code></pre>
  
  <p>ERROR:  invalid input value for enum khstate: "form"  </p>
  
  <pre><code>UPDATE tablename SET state = 'form'::khstate WHERE id = 100004;
  </code></pre>
  
  <p>ERROR:  invalid input value for enum khstate: "form"</p>
  
  <p>but without success. I am using the latest <a href="http://bitnami.org/stack/lappstack" rel="nofollow">BitNami LAPPstack</a>, so the version of PostgreSQL is 9.1.1.</p>
  
  <p>I havent added any RULE or TRIGGER constraints, nor have I used transactions explicitly.</p>
  
  <p>I tried to google for a solution, but all I could find were questions how to change the enum type itself, rather than the value of a column.</p>