pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: Russell Keane <Russell.Keane@inps.co.uk>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Create Type with typmod_in
Date: Fri, 4 Nov 2011 10:33:14 -0400
Message-ID: <F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com> (raw)
In-Reply-To: <8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk>
References: <8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk>

On Nov 4, 2011, at 10:01, Russell Keane <Russell.Keane@inps.co.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.


> 

view thread (2+ messages)

Message-ID: <F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com>
Permalink:  ../F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com/
Also on:    postgresql.org/message-id/F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: polobo@yahoo.com, Russell.Keane@inps.co.uk
  Subject: Re: Create Type with typmod_in
  In-Reply-To: <F8B81014-4F36-4192-8A73-E2A5B335F013@yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox