On functions and stored procs

From: "Graeme Merrall" <graeme(at)clubnet(dot)net(dot)au>
To: <pgsql-general(at)postgresql(dot)org>
Subject: On functions and stored procs
Date: 2000-04-19 04:38:09
Message-ID: 005001bfa9b9$10dfce90$373c57cb@clubnetisp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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. The examples
in the docs revolve more about creating functions from, well, a function
point of view rather than a stored procedure type of view.
In that I should probably say my only exposure with SP's in from MS-SQL so I
mean that definition. :)

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?
As an example, I query a table for a set of user accounts that need
processing on a certain day (today). Is it possible to query the table,
return a set of results then loop through those results and on each pass,
insert data into another table(s)?
The conditional I'm referring to in the docs is
[<<label>>]
FOR record | row IN select_clause LOOP
statements
END LOOP;

Any examples of this sort of thing? Quiet obviously, the docs generally need
updating when it comes to functions. Is there a documentation project/team?

Regards,
Graeme

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Manuel Lemos 2000-04-19 07:47:06 Re: Connecting website with SQL-database.....
Previous Message Alex Pilosov 2000-04-19 04:08:04 Re: Connecting website with SQL-database.....