Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1206EB5DBC1 for ; Fri, 4 Nov 2011 11:33:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 21476-03 for ; Fri, 4 Nov 2011 14:33:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from nm22-vm1.bullet.mail.ne1.yahoo.com (nm22-vm1.bullet.mail.ne1.yahoo.com [98.138.90.252]) by mail.postgresql.org (Postfix) with SMTP id 06963B5D91F for ; Fri, 4 Nov 2011 11:33:14 -0300 (ADT) Received: from [98.138.90.56] by nm22.bullet.mail.ne1.yahoo.com with NNFMP; 04 Nov 2011 14:33:14 -0000 Received: from [98.138.89.233] by tm9.bullet.mail.ne1.yahoo.com with NNFMP; 04 Nov 2011 14:33:14 -0000 Received: from [127.0.0.1] by omp1048.mail.ne1.yahoo.com with NNFMP; 04 Nov 2011 14:33:14 -0000 X-Yahoo-Newman-Id: 216120.449.bm@omp1048.mail.ne1.yahoo.com Received: (qmail 44079 invoked from network); 4 Nov 2011 14:33:14 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=ngj/br22RSeeepJXLgwvAYWn6c6BluNtIwINpKA4hBLUWbdL0kLsgCPK09ar+EnPItagK1BGxQzYGlC/ytoloyOPO0xPSwCTEhU6jpwsd+HodGn81vbhDsDvp7gmDF97cRdgRsZXLylk/QkCB0rTEs4rrnDvH8lTtd1tnPyxBJ8= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1320417194; bh=QPmcyqdySYhNqP4XAysfn8ZE6pdt0mSKSISuJ9JwXO4=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:References:Mime-Version:In-Reply-To:X-Apple-Yahoo-Original-Message-Folder:Content-Type:Content-Transfer-Encoding:Message-Id:Cc:X-Mailer:From:X-Apple-Yahoo-Replied-Msgid:Subject:Date:To; b=t20wBl2wgnggOf7fYk5Jw6lFc79ImAR2RFTdHZx2uOM/RX1jBAT5s+t6rruQnSnvSUSowGcu14cggHPrF1Laci9Jp3Ayu4P9GoJrsq7Z/4tfwpc3oaBH+SN/MQy7GJgvMkIJ3U69/f83HK97ks+G1By7vCU2AqSTsE4BYaT7SPw= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: pn6CiZ4VM1k2WReiwSQFUTakPAb4EaY.QdMNdKH_dDFQ8qP StdTMo1KcZZFpNLDFzy.dTd6DFE1DMWF.L.G9hX12dW4v5AvEpAlryWtXki. 86NB4C9u1K1hgWS7mRT40S_Dn7f7ZlfFhJiqTeBJv.Zfl1LuybNEWfb.ZScP uIaRNU4hkq8StrI7tB5Ulvwl2Zk74UiyMoXWm8qGJhPb3iZ3kqGck.2GAZ1Q 1XSMFMyZEECLRfs4XTKw.pj0Z5hIhUM1IZBR0.yRLFGPzvpwPT26pA0Vh.mW _HSeaRs48WAp57Rx95vTcI9xWxIIhv4A0UAQ3cSbV_8.zztK2OpcP0yQbmrx pHyG_BPrm8kREVRh37D6O8fv21ch4mDXNO0bPKWXX.rMe2utw6Ar0ozDzrj3 1Ujg5ew-- X-Yahoo-SMTP: mpGJl6eswBD2IBufoVEg0Pa8gg-- Received: from [192.12.17.103] (polobo@24.93.23.188 with xymcookie) by smtp112-mob.biz.mail.ne1.yahoo.com with SMTP; 04 Nov 2011 07:33:13 -0700 PDT References: <8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk> Mime-Version: 1.0 (iPad Mail 8J2) In-Reply-To: <8D0E5D045E36124A8F1DDDB463D548557CC7AB3991@mxsvr1.is.inps.co.uk> X-Apple-Yahoo-Original-Message-Folder: Inbox Content-Type: multipart/alternative; boundary=Apple-Mail-13-660095563 Content-Transfer-Encoding: 7bit Message-Id: Cc: "pgsql-sql@postgresql.org" X-Mailer: iPad Mail (8J2) From: David Johnston X-Apple-Yahoo-Replied-Msgid: 1_473219_AO+kiGIAAMVnTrPy1glj2hSKWr8 Subject: Re: Create Type with typmod_in Date: Fri, 4 Nov 2011 10:33:14 -0400 To: Russell Keane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.099 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/12 X-Sequence-Number: 35985 --Apple-Mail-13-660095563 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On Nov 4, 2011, at 10:01, Russell Keane wrote: > I=E2=80=99m trying to create a custom type (PostgreSQL 9.0) which will ess= entially auto truncate a string to a certain length. >=20 > =20 >=20 >=20 >=20 > Can this be done purely in plpgsql? >=20 > If so, how? >=20 > =20 >=20 An explicit cast of a value to varchar(n) causes the value to be truncated t= o n characters. E.g., '1234567'::varchar(5) -> '12345' How to integrate that knowledge into a type I do not know. David J. >=20 --Apple-Mail-13-660095563 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On Nov 4, 2011, at 10:01, Russell Keane= <Russell.Keane@inps.co.uk> wrote:


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

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

How t= o integrate that knowledge into a type I do not know.

David J.


=
= --Apple-Mail-13-660095563--