PL/PGSQL: another Q 
Author Message
 PL/PGSQL: another Q

I've gone through the books I have and searched the web but can't find
an answer to this question.

Is it possible to have a plpgsql function return a result set (rows)? If
so what do I declare the return type as?

I know it sounds silly but the reason would be that I have these
extremely long queries that I hate typing. I'd love to just create a
function, do a "SELECT myfunc(1,2,3,4,5,6,7)" and have the function spew
out the result set (rows). So far I can only find example on how to get
PL/PGSQL to return a single value.

Can this be done in PL/PGSQL?

Any pointers to reference material greatly appreciated!

Jc

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://www.***.com/



Tue, 05 Jul 2005 15:01:17 GMT
 PL/PGSQL: another Q

Quote:

> I've gone through the books I have and searched the web but can't find
> an answer to this question.

> Is it possible to have a plpgsql function return a result set (rows)? If
> so what do I declare the return type as?

> I know it sounds silly but the reason would be that I have these
> extremely long queries that I hate typing. I'd love to just create a
> function, do a "SELECT myfunc(1,2,3,4,5,6,7)" and have the function spew
> out the result set (rows). So far I can only find example on how to get
> PL/PGSQL to return a single value.

> Can this be done in PL/PGSQL?

As of 7.3 it can be done reasonably.  You might want to look at the
document on set returning functions that was just put up on techdocs.

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Tue, 05 Jul 2005 15:13:20 GMT
 PL/PGSQL: another Q
This is available is 7.3 version.
See http://developer.postgresql.org/docs/postgres/xfunc-sql.html#AEN31522

Patrick

----------------------------------------------------------------------------
---------------
Patrick Fiche

tl : 01 69 29 36 18
----------------------------------------------------------------------------
---------------

Quote:
-----Original Message-----


Imbeault
Sent: Friday, January 17, 2003 7:34 AM
To: pgsql-general
Subject: [GENERAL] PL/PGSQL: another Q

I've gone through the books I have and searched the web but can't find
an answer to this question.

Is it possible to have a plpgsql function return a result set (rows)? If
so what do I declare the return type as?

I know it sounds silly but the reason would be that I have these
extremely long queries that I hate typing. I'd love to just create a
function, do a "SELECT myfunc(1,2,3,4,5,6,7)" and have the function spew
out the result set (rows). So far I can only find example on how to get
PL/PGSQL to return a single value.

Can this be done in PL/PGSQL?

Any pointers to reference material greatly appreciated!

Jc

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Tue, 05 Jul 2005 15:59:09 GMT
 PL/PGSQL: another Q
Sorry for the previous wrong answer, if was SQL Functions...
Here is the link for PL/pgSQL functions
http://techdocs.postgresql.org/guides/SetReturningFunctions

----------------------------------------------------------------------------
---------------
Patrick Fiche

tl : 01 69 29 36 18
----------------------------------------------------------------------------
---------------

Quote:
-----Original Message-----


Imbeault
Sent: Friday, January 17, 2003 7:34 AM
To: pgsql-general
Subject: [GENERAL] PL/PGSQL: another Q

I've gone through the books I have and searched the web but can't find
an answer to this question.

Is it possible to have a plpgsql function return a result set (rows)? If
so what do I declare the return type as?

I know it sounds silly but the reason would be that I have these
extremely long queries that I hate typing. I'd love to just create a
function, do a "SELECT myfunc(1,2,3,4,5,6,7)" and have the function spew
out the result set (rows). So far I can only find example on how to get
PL/PGSQL to return a single value.

Can this be done in PL/PGSQL?

Any pointers to reference material greatly appreciated!

Jc

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Tue, 05 Jul 2005 16:04:21 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. pgsql/src/pl/plperl Makefile.PL

2. pgsql-server/src/pl/plpython error.expected pl ...

3. pgsql/src/pl/plpgsql/src Tag: REL7_1_STABLE pl ...

4. pgsql/src/pl/plpgsql/src Tag: REL7_2_STABLE pl ...

5. Performance of c, pl/perl, pl/pgsql

6. pgsql/src/pl/plpgsql/src Tag: REL7_1_STABLE pl ...

7. pgsql/contrib/intarray/bench (bench.pl create_test.pl)

8. pgsql/ ontrib/rtree_gist/rtree_gist.c rc/pl/pl ...

9. pgsql/src/pl/plpgsql/src Tag: REL7_2_STABLE pl ...

10. Converting PL/SQL to PL/PGSQL

11. PL/PGSQL and PL/Perl time issues

12. pgsql-server/src/pl/plpython plpython.c


 
Powered by phpBB® Forum Software