From: <Bil...@mu...> - 2003-01-05 02:21:12
|
Oliver Vecernik wrote: > Billy G. Allie schrieb: > > [...] > > > > Support for reference cursors was added. Since PostgreSQL 7.2, you could > > create cursors in PL/pgSQL and pass a reference to the open cursor back to > > the client. PgSQL will now cast those referenced cursors into a Cursor > > object that can be used to fetch the results in the cursor. For example > > (assuming that mmYearInfo() returns a reference curosr): > > Is it possible to get the source for mmYearInfo() to run this sample? Here is the source for mmYearInfo(). It can be used as an example for creating functions that returns a reference cursor, but it will not work without the schema and data. Unfortunately, the schema and data are not mine to give. CREATE FUNCTION mmyearinfo () RETURNS refcursor AS ' DECLARE ref refcursor; BEGIN OPEN ref FOR SELECT t1.model_year, t1.mktg_div_name, t1.model_desc, t1.book_types, t3.vehicle_syskey FROM mmyearen t1, mktgdiv t2, vehicle t3 WHERE t1.model_year = t3.model_year AND t1.mktg_div_name = t2.mktg_div_name AND t1.model_desc = t3.model_desc AND t2.mktg_div_id = t3.mktg_div_id AND t3.lang_code = ''EN'' ORDER BY model_year DESC, mktg_div_name, model_desc; RETURN ref; END; ' LANGUAGE plpgsql; -- ____ | Billy G. Allie | Domain....: Bil...@mu... | /| | 7436 Hartwell | MSN.......: B_G...@em... |-/-|----- | Dearborn, MI 48126| |/ |LLIE | (313) 582-1540 | |