Re: plpgsql arrays

Поиск
Список
Период
Сортировка
От justin
Тема Re: plpgsql arrays
Дата
Msg-id 49DB74FC.9080705@emproshunts.com
обсуждение исходный текст
Ответ на Re: plpgsql arrays  (Matthew Wakeling <matthew@flymine.org>)
Список pgsql-performance
Matthew Wakeling wrote: <blockquote cite="mid:alpine.DEB.2.00.0904071630420.791@aragorn.flymine.org" type="cite">On
Tue,7 Apr 2009, justin wrote: <br /><blockquote type="cite"><blockquote type="cite">What would be the syntax for
puttinga single row from a cursor into a variable? I have tried: <br /><br /> FETCH INTO left left_cursor; <br /><br />
whichsays syntax error, and <br /><br /> left = FETCH left_cursor; <br /><br /> which gives the error 'ERROR:  missing
datatypedeclaration at or near "="' <br /></blockquote><br /> Have to declare Left variable  as record data type
declarationpart of the function <br /></blockquote><br /> It is. <br /><br /> CREATE OR REPLACE FUNCTION
overlap_gene_primer()RETURNS SETOF RECORD AS $$ <br /> DECLARE <br />     left location; <br />     retval RECORD; <br
/>BEGIN <br />     DECLARE left_cursor NO SCROLL CURSOR FOR SELECT location FROM location, gene WHERE location.id =
gene.idORDER BY objectid, start, end; <br />     left = FETCH left_cursor; <br /> END; <br /> $$ LANGUAGE plpgsql; <br
/><br/> Matthew <br /></blockquote><br /> Change the type to Record<br /> from the help file<br /><code
class="command">FETCH</code>retrieves the next row from the cursor into a target, which might be a <b>row variable, a
recordvariable, or a comma-separated </b>list of simple variables, just like <code class="command">SELECT INTO</code>.
Ifthere is no next row, the target is set to NULL(s). As with <code class="command">SELECT INTO</code>, the special
variable<code class="literal">FOUND</code> can be checked to see whether a row was obtained or not<br /><br /> 

В списке pgsql-performance по дате отправления:

Предыдущее
От: Matthew Wakeling
Дата:
Сообщение: Re: plpgsql arrays
Следующее
От: Tom Lane
Дата:
Сообщение: Re: plpgsql arrays