SetOf Functions

Started by Joshua D. Drakeover 20 years ago5 messages
#1Joshua D. Drake
jd@commandprompt.com

Hello,

O.k. I know I can do:

CREATE FUNCTION foo() RETURNS SET OF text AS ' ' language SQL;

Does anyone else think it would be nice to be able to do:

CREATE FUNCTION foo() RETURNS SET OF text,int4,float,timestamp AS ' '
language SQL;

?

We could even extend it farther:

CREATE FUNCTION foo() RETURNS SET OF text AS first_name, int4 AS id etc....

Sincerely,

Joshua D. Drake

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

#2Andrew Dunstan
andrew@dunslane.net
In reply to: Joshua D. Drake (#1)
Re: SetOf Functions

Joshua D. Drake wrote:

Hello,

O.k. I know I can do:

CREATE FUNCTION foo() RETURNS SET OF text AS ' ' language SQL;

Does anyone else think it would be nice to be able to do:

CREATE FUNCTION foo() RETURNS SET OF text,int4,float,timestamp AS ' '
language SQL;

?

We could even extend it farther:

CREATE FUNCTION foo() RETURNS SET OF text AS first_name, int4 AS id
etc....

You mean like this?

create type bar (firstname text, id int);
create function foo() returns setof bar as ' ' language sql;

cheers

andrew

#3Josh Berkus
josh@agliodbs.com
In reply to: Joshua D. Drake (#1)
Re: SetOf Functions

Josh,

CREATE FUNCTION foo() RETURNS SET OF text,int4,float,timestamp AS ' '
language SQL;

You can effectively do this with the new INOUT syntax. Check it out in the
8.1devel docs.

--
Josh Berkus
Aglio Database Solutions
San Francisco

#4Joshua D. Drake
jd@commandprompt.com
In reply to: Andrew Dunstan (#2)
Re: SetOf Functions

You mean like this?

create type bar (firstname text, id int);
create function foo() returns setof bar as ' ' language sql;

No. I am aware I can do that ;) I don't want to have to create
the type ahead of time :)

Sincerely,

Joshua D. Drake

cheers

andrew

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/

#5Joshua D. Drake
jd@commandprompt.com
In reply to: Josh Berkus (#3)
Re: SetOf Functions

Josh Berkus wrote:

Josh,

CREATE FUNCTION foo() RETURNS SET OF text,int4,float,timestamp AS ' '
language SQL;

You can effectively do this with the new INOUT syntax. Check it out in the
8.1devel docs.

Cool thanks... (takes note to document in the book)

--
Your PostgreSQL solutions company - Command Prompt, Inc. 1.800.492.2240
PostgreSQL Replication, Consulting, Custom Programming, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/