From: | Matthew Wakeling <matthew(at)flymine(dot)org> |
---|---|
To: | justin <justin(at)emproshunts(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: plpgsql arrays |
Date: | 2009-04-07 15:33:30 |
Message-ID: | alpine.DEB.2.00.0904071630420.791@aragorn.flymine.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Tue, 7 Apr 2009, justin wrote:
>> What would be the syntax for putting a single row from a cursor into a
>> variable? I have tried:
>>
>> FETCH INTO left left_cursor;
>>
>> which says syntax error, and
>>
>> left = FETCH left_cursor;
>>
>> which gives the error 'ERROR: missing datatype declaration at or near "="'
>
> Have to declare Left variable as record data type declaration part of the
> function
It is.
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;
Matthew
--
"Prove to thyself that all circuits that radiateth and upon which thou worketh
are grounded, lest they lift thee to high-frequency potential and cause thee
to radiate also. " -- The Ten Commandments of Electronics
From | Date | Subject | |
---|---|---|---|
Next Message | justin | 2009-04-07 15:45:00 | Re: plpgsql arrays |
Previous Message | justin | 2009-04-07 15:23:59 | Re: plpgsql arrays |