Re: check if type is valid pg type

From: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
To: Dominik Moritz <domoritz(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: check if type is valid pg type
Date: 2012-10-10 21:20:26
Message-ID: CAK3UJRHF5vA=VKxZhwVHdeQzNMPxXHpCMm86KgKyjtJurTf=nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, Oct 1, 2012 at 3:47 PM, Dominik Moritz <domoritz(at)gmail(dot)com> wrote:
> I need to check, whether a type is a valid postgres type or not. My first take was to check in the pg_type table. However, pg_type does not list types such as integer (but it does list int4) or float (but it does indeed list float8). What is the best way to check whether a type is valid or not?

You could cast the type name to regtype, e.g.

SELECT 'integer'::regtype, 'float'::regtype;

Josh

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message James David Smith 2012-10-12 10:16:00 Make UPDATE query quicker?
Previous Message robert wing 2012-10-10 01:49:10 selecting all tables with references