pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to create a type ?
3+ messages / 3 participants
[nested] [flat]
* How to create a type ?
@ 2001-02-13 16:20 Ines Klimann <Ines.Klimann@liafa.jussieu.fr>
2001-02-14 16:00 ` Re: How to create a type ? Tom Lane <tgl@sss.pgh.pa.us>
2001-02-14 18:14 ` Re: How to create a type ? Jie Liang <jliang@ipinc.com>
0 siblings, 2 replies; 3+ messages in thread
From: Ines Klimann @ 2001-02-13 16:20 UTC (permalink / raw)
To: pgsql-sql
Hello,
I am trying to understand how works CREATE TYPE, but it seems to
be too difficult for me...
Can someone help me ?
I have tried this :
----------------------------------
create function personne_in(text)
returns personne
as 'select $1;'
language 'sql';
create function personne_out(text)
returns text
as 'select $1;'
language 'sql';
create type personne (
internallength = variable,
input = personne_in,
output = personne_out
);
---------------------------------
but it is full of mistakes.
Even a simple example in language 'sql' will help me.
Thanks,
Ines.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to create a type ?
2001-02-13 16:20 How to create a type ? Ines Klimann <Ines.Klimann@liafa.jussieu.fr>
@ 2001-02-14 16:00 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2001-02-14 16:00 UTC (permalink / raw)
To: Ines.Klimann@liafa.jussieu.fr; +Cc: pgsql-sql
Ines Klimann <Ines.Klimann@liafa.jussieu.fr> writes:
> I have tried this :
> ----------------------------------
> create function personne_in(text)
> returns personne
> as 'select $1;'
> language 'sql';
> create function personne_out(text)
> returns text
> as 'select $1;'
> language 'sql';
> create type personne (
> internallength = variable,
> input = personne_in,
> output = personne_out
> );
> ---------------------------------
> but it is full of mistakes.
Can't do it that way, because SQL functions can't produce or consume
the plain C strings that input/output conversion functions have to
deal with. There's really no way to write an input or output function
except in C.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: How to create a type ?
2001-02-13 16:20 How to create a type ? Ines Klimann <Ines.Klimann@liafa.jussieu.fr>
@ 2001-02-14 18:14 ` Jie Liang <jliang@ipinc.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jie Liang @ 2001-02-14 18:14 UTC (permalink / raw)
To: Ines Klimann <Ines.Klimann@liafa.jussieu.fr>; +Cc: pgsql-sql
hope it helps.
e.g.
create function foo() returns setof varchar as '
select name from categories '
language 'sql';
db=# select foo() as name;
name
---------------------------------
recreation
business
web
education
questionable
sex
social
society
weapons/bombs
mature humor
pornography
tasteless
computer hacking
nudity
drugs
lingerie/bikini
profanity
.......
Jie LIANG
St. Bernard Software
Internet Products Inc.
10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873
jliang@ipinc.com
www.stbernard.com
www.ipinc.com
On Tue, 13 Feb 2001, Ines Klimann wrote:
> Hello,
>
> I am trying to understand how works CREATE TYPE, but it seems to
> be too difficult for me...
>
> Can someone help me ?
>
> I have tried this :
> ----------------------------------
> create function personne_in(text)
> returns personne
> as 'select $1;'
> language 'sql';
>
> create function personne_out(text)
> returns text
> as 'select $1;'
> language 'sql';
>
> create type personne (
> internallength = variable,
> input = personne_in,
> output = personne_out
> );
> ---------------------------------
> but it is full of mistakes.
>
> Even a simple example in language 'sql' will help me.
>
> Thanks,
> Ines.
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-02-14 18:14 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-13 16:20 How to create a type ? Ines Klimann <Ines.Klimann@liafa.jussieu.fr>
2001-02-14 16:00 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-02-14 18:14 ` Jie Liang <jliang@ipinc.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