title: PostgreSQL return a function with a Custom Data Type
body: <p>I want to create a function that returns a type that I made, but when I execute it, it says that the type doesn't exists. I assume that's cause it doesn't know about the custom type.</p>
  
  <p>UDT:</p>
  
  <pre><code>CREATE TYPE building_code AS ENUM ('IT','EMS','HSB','ENG');
  </code></pre>
  
  <p>Function:</p>
  
  <pre><code> CREATE FUNCTION roomCode(id int ) RETURNS building_code AS 
  $$
   SELECT building_code FROM venue as v WHERE id = v.id;
  $$ LANGUAGE SQL;
  </code></pre>