Create Type with typmod_in

From: Russell Keane <Russell(dot)Keane(at)inps(dot)co(dot)uk>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Create Type with typmod_in
Date: 2011-11-04 14:01:49
Message-ID: 8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm trying to create a custom type (PostgreSQL 9.0) which will essentially auto truncate a string to a certain length.

The type (auto_trunc_char) will be used as follows:

Create table blah (
Some_name auto_trunc_char(40)
)

Can this be done purely in plpgsql?
If so, how?

I know I have to declare the following (at least) but I'm not sure how to flesh out the functions:

create type auto_trunc_char (
INTERNALLENGTH = VARIABLE,
INPUT = auto_trunc_char_in_function,
OUTPUT = auto_trunc_char_out_function,
TYPMOD_IN = auto_trunc_char_modifier_in
);

Regards,

Russell Keane

INPS

Subscribe to the Vision e-newsletter<http://www.inps4.co.uk/news/enewsletter/>
Subscribe to the Helpline Support Bulletin<http://www.inps4.co.uk/my_vision/helpline/support-bulletins>
[cid:image001(dot)png(at)01CC9AFA(dot)4BF01AF0] Subscribe to the Helpline Blog RSS Feed<http://www.inps4.co.uk/rss/helplineblog.rss>

________________________________
Registered name: In Practice Systems Ltd.
Registered address: The Bread Factory, 1a Broughton Street, London, SW8 3QJ
Registered Number: 1788577
Registered in England
Visit our Internet Web site at www.inps.co.uk
The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of INPS or any of its affiliates. If you are not the intended recipient please contact is(dot)helpdesk(at)inps(dot)co(dot)uk

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2011-11-04 14:33:14 Re: Create Type with typmod_in
Previous Message Michael Glaesemann 2011-11-03 18:20:40 Re: intervals