From: | "Chris Hoover" <revoohc(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Fwd: Help with function |
Date: | 2006-10-04 13:31:28 |
Message-ID: | 1d219a6f0610040631u4b980578nb6827a0f46c1cf6c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I did not see this go through.
Chris
---------- Forwarded message ----------
From: Chris Hoover <revoohc(at)gmail(dot)com>
Date: Oct 3, 2006 4:49 PM
Subject: Help with function
To: pgsql-general(at)postgresql(dot)org
I need some help with writing a plpgsql function. I want to return multiple
items from the function. How do I do this?
Here is my attempt at the function (note, this is a simple example that
could obviously be done via a view, but I am trying to learn more about
writing plpgsql functions):
create or replace function dba.active_transactions_by_db() returns setof
integer pg_stat_activity.datname%TYPE as
$BODY$
declare
dbName varchar;
activeTransactions integer;
countRec record;
begin
for countRec in select count(1) as cnt, datname from pg_stat_activity
group by datname loop
return next countRec;
end loop;
return countRec;
end;
$BODY$
language plpgsql;
From | Date | Subject | |
---|---|---|---|
Next Message | stevegy | 2006-10-04 13:45:26 | Re: Hi,&nbs |
Previous Message | Chris Kratz | 2006-10-04 12:59:23 | Re: Need help with a function from hell.. |