Re: plpgsql arrays

Поиск
Список
Период
Сортировка
Искать
От
Matthew Wakeling
Тема
Re: plpgsql arrays
Дата
Msg-id
alpine.DEB.2.00.0904071719320.791@aragorn.flymine.org
Ответ на
Список
Дерево обсуждения
plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays justin <justin@emproshunts.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays justin <justin@emproshunts.com>
Re: plpgsql arrays Merlin Moncure <mmoncure@gmail.com>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Robert Haas <robertmhaas@gmail.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Simon Riggs <simon@2ndQuadrant.com>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Alvaro Herrera <alvherre@commandprompt.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Robert Haas <robertmhaas@gmail.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Tom Lane <tgl@sss.pgh.pa.us>
Re: plpgsql arrays Nathan Boley <npboley@gmail.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Merlin Moncure <mmoncure@gmail.com>
Re: plpgsql arrays Merlin Moncure <mmoncure@gmail.com>
Re: plpgsql arrays Matthew Wakeling <matthew@flymine.org>
Re: plpgsql arrays Merlin Moncure <mmoncure@gmail.com>
On Tue, 7 Apr 2009, Tom Lane wrote:
> Matthew Wakeling  writes:
>> CREATE OR REPLACE FUNCTION overlap_gene_primer() RETURNS SETOF RECORD AS $$
>> DECLARE
>>      left location;
>>      retval RECORD;
>> BEGIN
>>      DECLARE left_cursor NO SCROLL CURSOR FOR SELECT location FROM location, gene WHERE location.id = gene.id ORDER BY objectid, start, end;
>>      left = FETCH left_cursor;
>> END;
>> $$ LANGUAGE plpgsql;
>
> Well, the DECLARE for the cursor should go in the DECLARE section,
> and the syntax for the FETCH should be
> 	FETCH cursorname INTO recordvariablename;
> and I'm too lazy to check right now but I think you might be missing
> an OPEN for the cursor.

Yeah, thanks to Justin I found the plpgsql docs for cursors. The main 
cursors docs should really link there.

This seems to do what I want:

CREATE OR REPLACE FUNCTION overlap_gene_primer() RETURNS SETOF RECORD AS 
$$
DECLARE
     left_cursor NO SCROLL CURSOR FOR SELECT location.* FROM location, gene WHERE location.subjectid = gene.id ORDER BY objectid, start, end;
     left location;
BEGIN
     OPEN left_cursor;
     FETCH left_cursor INTO left;
END;
$$ LANGUAGE plpgsql;

Matthew

-- 
 Lord grant me patience, and I want it NOW!
В списке pgsql-performance по дате отправления
От: Andrew Sullivan
Дата:
Сообщение: Re: Best replication solution?
От: Andrew Sullivan
Дата:
Сообщение: Re: Best replication solution?
FAQ