Re: [SQL] Create Type with typmod_in

2011-11-04 Thread David Johnston
On Nov 4, 2011, at 10:01, Russell Keane 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) ca

Re: [SQL] CREATE TYPE

2004-11-03 Thread sad
Hello i note something related to this discussion > create table mytmp(name myvarchar(10,"en_US")); i meant that "en_US" is a locale name, then it means natural language and also character encoding -- those both things are not a matter of SQL-TYPE at all. It is wrong to represent application

Re: [SQL] CREATE TYPE

2004-11-03 Thread Jeff
On Nov 3, 2004, at 10:56 AM, Ameen - Etemady wrote: I like to do it like this: create table mytmp(name myvarchar(10,"en_US")); you can't unless you modify the parser. It has special cases to support varchar (and numeric) syntax. -- Jeff Trout <[EMAIL PROTECTED]> http://www.jefftrout.com/ http://ww

Re: [SQL] CREATE TYPE VARCHAR2

2004-08-25 Thread Tom Lane
Sascha Ziemann <[EMAIL PROTECTED]> writes: > I would like to define a > new type VARCHAR2 which should behave exactly like VARCHAR. You could get about halfway there with CREATE DOMAIN varchar2 AS varchar; But it's only halfway because the domain will not accept length decorations; that i

Re: [SQL] create type input and output function examples

2003-11-04 Thread Christoph Haller
> > I've seen the docs for create type and an example of the syntax to create a > type. What I haven't seen is the functions that are passed for the input and > output elements. > > CREATE TYPE box (INTERNALLENGTH = 8, > INPUT = my_procedure_1, OUTPUT = my_procedure_2); > > Now what would

Re: [SQL] CREATE TYPE function examples

2001-07-10 Thread Tom Lane
Roberto Mello <[EMAIL PROTECTED]> writes: > What would the functions my_procedure_1 and my_procedure_2 look like? src/backend/utils/adt/ is full of examples of datatype I/O procedures. Pick an existing type that does something vaguely like your type (at the very least pick one that uses the same

Re: [SQL] CREATE TYPE function examples

2001-07-10 Thread Roberto Mello
On Tue, Jul 10, 2001 at 06:43:59PM +0200, Peter Eisentraut wrote: > > http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xtypes.html Oh. So you have to write a function in C to use CREATE TYPE? > This seems to be outdated regarding the fmgr update, though. (Hint, > hint...)

Re: [SQL] CREATE TYPE function examples

2001-07-10 Thread Peter Eisentraut
Roberto Mello writes: > I'm looking for some examples of how the functions for CREATE TYPE > should be. There are none in the documentation, so I was hoping to find > someone here that could help me. http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xtypes.html This seems to be