Re: Can I create a TYPE (or DOMAIN) with arguments?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: R(dot)A(dot) <adeveloper(at)bluebottle(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Can I create a TYPE (or DOMAIN) with arguments?
Date: 2008-01-10 15:29:49
Message-ID: b42b73150801100729h423bfc89g54afdc965d3613a3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jan 9, 2008 4:53 AM, R.A. <adeveloper(at)bluebottle(dot)com> wrote:
> Hello,
>
> I'm trying to create a composite type with an argument, to create one field of this type like character varying(x), but I don't know if this can be done with PostgreSQL. I want something like:
> CREATE TYPE mytype AS (
> tx character varying(x),
> t2nd integer
> );
> I need to limit the number of chars in this field tx. And different lengths will be used when creating tables with this type (so a Domain will suffer the same problem). I'm not looking for a solution like a separate column with maxChars and a Check, because lots of columns will be required (and others design reasons).

It would be really neat if you could do that, but you can't :-(. What
you can do is make a trigger function taking mytype which and apply
the constraint that way...

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2008-01-10 15:30:23 Re: Postgres and MySQL Rosetta stone??
Previous Message Sim Zacks 2008-01-10 15:26:02 Re: 8.2.4 serious slowdown