Re: On functions and stored procs - Mailing list pgsql-general

From Ed Loehr
Subject Re: On functions and stored procs
Date
Msg-id 38FDBCAB.87898DBC@austin.rr.com
Whole thread Raw
In response to On functions and stored procs  ("Graeme Merrall" <graeme@clubnet.net.au>)
List pgsql-general
Graeme Merrall wrote:
>
> I'm just getting into functions in postgres and I've bumped up against a
> couple issues which I think I need explained. I've had a wee read of the
> archives on this but haven't turned up to much. I think it may be a
> conceptual problem on my part though :)
>
> Is it possible on postgres, using pl/pgsql to create a function that is
> essentially a stored procedure? i.e. go through and execute a series of SQL
> statements and return a value - success or failure for example.

Yes, this is possible with plpgsql.  Note you're limited to returning one
value, not a relation.

> Aditionally, from reading the docs on pl/pgsql is it possible to loop
> through a set of rows returned from a query and perform an action on each
> iteration?

Yes.

> Any examples of this sort of thing?

    .../src/test/regress/sql/plpgsql.sql

> Quiet obviously, the docs generally need
> updating when it comes to functions. Is there a documentation project/team?

    www.postgresql.org
>
> Regards,
>  Graeme

pgsql-general by date:

Previous
From: Javier Benito
Date:
Subject: Sorry, I forgot put the exception in my message...
Next
From: "Steve Wolfe"
Date:
Subject: well, shoot. Error loading Pg.so