pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCreate Type with typmod_in
2+ messages / 2 participants
[nested] [flat]
* Create Type with typmod_in
@ 2011-11-04 14:01 Russell Keane <Russell.Keane@inps.co.uk>
0 siblings, 1 reply; 2+ messages in thread
From: Russell Keane @ 2011-11-04 14:01 UTC (permalink / raw)
To: 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.png@01CC9AFA.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.helpdesk@inps.co.uk
Attachments:
[image/png] image001.png (816B, ../../8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk/3-image001.png)
download | view image
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Create Type with typmod_in
@ 2011-11-04 14:33 David Johnston <polobo@yahoo.com>
parent: Russell Keane <Russell.Keane@inps.co.uk>
0 siblings, 0 replies; 2+ messages in thread
From: David Johnston @ 2011-11-04 14:33 UTC (permalink / raw)
To: Russell Keane <Russell.Keane@inps.co.uk>; +Cc: pgsql-sql
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.
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-11-04 14:33 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-11-04 14:01 Create Type with typmod_in Russell Keane <Russell.Keane@inps.co.uk>
2011-11-04 14:33 ` David Johnston <polobo@yahoo.com>
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