Re: check if type is valid pg type

From: Dominik Moritz <domoritz(at)gmail(dot)com>
To: Josh Kupershmidt <schmiddy(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: check if type is valid pg type
Date: 2012-10-12 13:45:21
Message-ID: 667E7C54-F2BA-466A-86A2-128195026857@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Josh,

That is exactly what I needed. Thank you very much. However, is there a way to do this without getting an exception if the type does not exist?

Cheers,
Dominik

On Oct 10, 2012, at 23:20 , Josh Kupershmidt <schmiddy(at)gmail(dot)com> wrote:

> 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 VB N 2012-10-12 14:00:11 Re: Make UPDATE query quicker?
Previous Message James David Smith 2012-10-12 12:14:17 Re: Make UPDATE query quicker?