On Fri, Oct 12, 2012 at 6:45 AM, Dominik Moritz <domoritz@gmail.com> wrote:
> That is exactly what I needed. Thank you very much. However, is there a way to do this without getting an exception
ifthe type does not exist?
You could wrap the lookup in a little PL/pgSQL function, something like this:
CREATE OR REPLACE FUNCTION is_valid_type(v_type text)
RETURNS boolean
AS $$
BEGIN
PERFORM v_type::regtype;
RETURN true;
EXCEPTION WHEN undefined_object THEN
RETURN false;
END;
$$ LANGUAGE plpgsql stable;
Josh