Re: Create Type with typmod_in

From: David Johnston <polobo(at)yahoo(dot)com>
To: Russell Keane <Russell(dot)Keane(at)inps(dot)co(dot)uk>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Create Type with typmod_in
Date: 2011-11-04 14:33:14
Message-ID: F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Nov 4, 2011, at 10:01, Russell Keane <Russell(dot)Keane(at)inps(dot)co(dot)uk> wrote:

> I’m trying to create a custom type (PostgreSQL 9.0) which will essentially auto truncate a string to a certain length.
>
>
>
>
>
> Can this be done purely in plpgsql?
>
> If so, how?
>
>
>

An explicit cast of a value to varchar(n) causes the value to be truncated to n characters.

E.g., '1234567'::varchar(5) -> '12345'

How to integrate that knowledge into a type I do not know.

David J.

>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message John Fabiani 2011-11-04 14:38:29 the use of $$string$$
Previous Message Russell Keane 2011-11-04 14:01:49 Create Type with typmod_in