From: | SamPost <everywhereboy(at)yahoo(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Creating a Cursor / Returning multiple rows |
Date: | 2002-09-03 20:06:54 |
Message-ID: | 20020903200654.5665.qmail@web40306.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I am trying to create a PLPGSQL function that takes in
an SQL statement as a parameter, Executes it, then
iterates over the results and returns all the rows
from that query that meet some extra requirements.
That is to say,
CREATE OR REPLACE myfunc(TEXT, TEXT, INTEGER) RETURNS
REFCURSOR AS '
.
.
.
sql ALIAS for $1;
restraints ALIAS for $2;
num_buckets ALIAS for $3;
.
.
.
FOR z IN EXECUTE (sql) LOOP
.
(sql is like "select * from table1, table2...")
use z to get info from table3 and check against
restraints (alias for $1, remember?)
if z meets restraints, add to res
.
END LOOP;
RETURN res;
HelP?
Sam
=====
Sam Post
Synapse Interaction Facilitator
*MyndSparqz Services*
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2002-09-03 21:17:32 | Re: parameterized views? |
Previous Message | Stephan Szabo | 2002-09-03 19:55:15 | Re: DELETE SQL too slow. |