Re: Retrieve columntypes and checks?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jesper Krogh <jesper(at)krogh(dot)cc>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Retrieve columntypes and checks?
Date: 2004-10-28 17:37:00
Message-ID: 20041028173700.GB12318@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Oct 28, 2004 at 10:27:30 +0000,
Jesper Krogh <jesper(at)krogh(dot)cc> wrote:
> Trying to convert an application from MySQL to PostgreSQL I ran into
> some troubles..
>
> In MySQL is it quite easy to find out which type a column is.. in
> particular if a column is an "enum" so the webapplication can do
> appropiate checks in javascript in advance for an insert.
>
> In PostgreSQL the enum's are converted to varchar with checks, so I need
> to get a hold on the column-type and if it's a varchar parse the check
> string for values..
>
> How do I do that?
>
> Any better suggestions?

A possible approach would be to use domains. That is probably a good practice
for this case anyway, since if an "enum" is used in more than one table,
you can have the constaint in one place. You should be able to get the
domain name associated with a column, but I don't know whether or not
this will require extra queries.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Aleksandar Dezelin 2004-10-28 18:41:33 Importing Microsoft Sql Server 2000
Previous Message Michael Fuhr 2004-10-28 17:33:20 Re: Retrieve columntypes and checks?