Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about returns "set"

Status
Not open for further replies.

thedumbkid

Programmer
May 13, 2003
9
US
Is returns "set" the same as returning a table???
by that I mean, if I have a function that returns "set"
can I do the following?

create function myfunction() returns "set" as '
begin
return [some SELECT statement here];
end;' language 'plpgsql';

if so, can somebody point me to some documentation on how to use this return type? I can't find a good resource for some reason :(

I know there's "returns setof record" and "returns refcursor"... but I'm hoping that returns "set" can make my life easier :p

reason I wanna do this is because I have many functions in SQL Server and a lot of them have RETURN TABLE...
 
 
hi rycamor, thank you for the links :)

I am converting everything from SQL Server to PostgreSQL for an application.
It's going to support Oracle, SQL Server and PostgreSQL so I need a solution
that's easy to maintain.

Is refcursor the only way to get a set of rows if I don't want to use
"returns setof record" and "returns setof my_own_type"?

Are there any other ways of returning a collection of rows??? Like in SQL Server
where you can just do RETURN [SELECT STATEMENT].

I have functions returning a SELECT query that gets columns from several
views/tables... using inner join and all that stuff...
Some of them return like 30 columns... imagine having to specify all those columns
in "select * from myfunction() as (...)" or CREATE TYPE to use for all those
functions...

"return record" and "return my_own_type" are hard to maintain in my case... and if
possible, I don't want to use those

just wondering if there's a good way of doing this
 
I imagine there should be some way to get a generic return, even if you need a small standardized piece of code at the beginning of each function. You should ask this question in the PostgreSQL mailing list (see to sign up). Try the pgsql-sql@postgresql.org list.

I'm pretty sure you will get a fairly workable solution. Often the head developers themselves will answer your questions ;-).

I'm curious about the answer to this also, so please let us know what you find out.

-------------------------------------------

My PostgreSQL FAQ --
 
got an answer from mailing list that this is not possible in postgresql yet

I am using user-defined types now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top