Thread: example table functions?

example table functions?

From
"culley harrelson"
Date:
Does anyone have some sample table functions they could post?  I read in
the archives about something in contrib but currently I only have 7.3
running in Cygwin (I am patiently waiting for the FreeBSD Postgresql port
to be updated to 7.3) and I don't see any sign of contrib on Cygiwn...
I'd love to tinker around with functions returning multiple rows without
guessing at the syntax :)

culley

Re: example table functions?

From
Joe Conway
Date:
culley harrelson wrote:
> Does anyone have some sample table functions they could post?  I read in
> the archives about something in contrib but currently I only have 7.3
> running in Cygwin (I am patiently waiting for the FreeBSD Postgresql port
> to be updated to 7.3) and I don't see any sign of contrib on Cygiwn...
> I'd love to tinker around with functions returning multiple rows without
> guessing at the syntax :)

You didn't say which language you were looking for examples in, but I recently
posted a plpgsql example here in Roberto Mello's PostgreSQL Cookbook:
http://www.brasileiro.net:8080/postgres/cookbook/view-one-recipe.adp?recipe_id=11378

There are other plpgsql and sql function examples in the mailing list
archives. Couple of examples:

   http://archives.postgresql.org/pgsql-general/2002-10/msg00022.php
and
   http://archives.postgresql.org/pgsql-general/2002-12/msg00426.php

There is a recent example in Elein Mustain's "General Bits" column:
http://archives.postgresql.org/pgsql-general/2002-12/msg00426.php

The contrib table functions are all C based. You can download them directly
from cvs -- for instructions see:
   http://developer.postgresql.org/TODO/docs/cvs.html#ANONCVS

or just to browse see:
   http://developer.postgresql.org/cvsweb.cgi/pgsql-server/contrib/dblink/
and
   http://developer.postgresql.org/cvsweb.cgi/pgsql-server/contrib/tablefunc/

And finally, in the manual see:

general ->
http://developer.postgresql.org/docs/postgres/xfunc-tablefunctions.html

sql ->
http://developer.postgresql.org/docs/postgres/xfunc-sql.html (sec 9.2.4)

C ->
http://developer.postgresql.org/docs/postgres/xfunc-c.html (sec 9.5.6)

plpgsql ->
http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html

usage ->
http://developer.postgresql.org/docs/postgres/sql-select.html (from_item,
inputs, from clause, usage)

Possibly others, but that's all I can think of.

HTH,

Joe


Re: example table functions?

From
Joe Conway
Date:
Joe Conway wrote:
> There is a recent example in Elein Mustain's "General Bits" column:
> http://archives.postgresql.org/pgsql-general/2002-12/msg00426.php
>

Oops! That was a cut-n-pasto. Here's the real link:
   http://www.varlena.com/GeneralBits/6.html

Joe