Skip site navigation (1) Skip section navigation (2)

Re: Passing multiple rows to a function?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Vitaly Belman <vitalyb(at)gmail(dot)com>
Cc: Postgresql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Passing multiple rows to a function?
Date: 2005-04-24 00:21:31
Message-ID: 20050424002130.GA61200@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Sun, Apr 24, 2005 at 03:00:55AM +0300, Vitaly Belman wrote:
>
> I know that you can pass rows/records to a function but what about a
> few rows? Is that possible?
> 
> For example, I'd like to send to a function a number of rows from the
> "workers" table (e.g "select * from workers where age<10") and the
> function will return their summed salary.

See "Aggregate Functions" in the PostgreSQL Tutorial, and again in
the "Functions and Operators" chapter.  Here are links to documentation
for the latest version of PostgreSQL:

http://www.postgresql.org/docs/8.0/interactive/tutorial-agg.html
http://www.postgresql.org/docs/8.0/interactive/functions-aggregate.html

If you want to create your own aggregate functions, see "User-Defined
Aggregates" in the "Extending SQL" chapter and the documentation
for CREATE AGGREGATE:

http://www.postgresql.org/docs/8.0/interactive/xaggr.html
http://www.postgresql.org/docs/8.0/interactive/sql-createaggregate.html

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

pgsql-novice by date

Next:From: Vitaly BelmanDate: 2005-04-24 08:48:57
Subject: Re: Passing multiple rows to a function?
Previous:From: Vitaly BelmanDate: 2005-04-24 00:00:55
Subject: Passing multiple rows to a function?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group