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

[SQL] Create Type with typmod_in

2011-11-04 Thread Russell Keane
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

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

[SQL] CREATE TYPE

2004-11-03 Thread Ameen - Etemady
I want to create a data type that have tow arguments in the defenition, like the varchar type: create table mytmp(name varchar(10)); I like to do it like this: create table mytmp(name myvarchar(10,"en_US")); whow can it be done by "CREATE TYPE" I want to implement the internal functions (compare,

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

[SQL] CREATE TYPE VARCHAR2

2004-08-25 Thread Sascha Ziemann
Hi, I try to emulate with PostgreSQL an Oracle database. My problem is that PostgreSQL does not support any Oracle specific types. PostgreSQL provides the TEXT and Oracle uses the CLOB or VARCHAR2 type. I would like to use the CREATE TYPE statement to tell PostgreSQL about the Oracle types, but

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

[SQL] create type input and output function examples

2003-10-28 Thread Clint Stotesbery
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 be in my_procedure1 a

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

[SQL] CREATE TYPE function examples

2001-07-10 Thread Roberto Mello
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. For example, the documentation has this example: CREATE TYPE box (INTERNALLENGTH = 8, INPUT = my_procedur

[SQL] create type of table

2001-07-06 Thread Jeff Barrett
I have a problem where I need to restrict queries by more than a million ids that are the result of another program. Typically I would in the application layer write those ids into an IN( ) clause, but that will not work for more than 10,000 ids. So I need to load these ids into the db into some s

[SQL] create type and domains

2001-05-11 Thread Valerio Santinelli
I'm trying to simulate domains in PostgreSQL using the create type function, but I cannot find how the input and output functions for standard types are called. Is there anyone who can help me ? Thanks!   --Valerio Santinelli