Using cursors inside PL/pgSQL function

Поиск
Список
Период
Сортировка
От Atul
Тема Using cursors inside PL/pgSQL function
Дата
Msg-id 003001c0cbc2$3e3c3140$5e05a8c0@atul
обсуждение исходный текст
Ответы Re: Using cursors inside PL/pgSQL function  (Ian Lance Taylor <ian@airs.com>)
Список pgsql-novice
Can't we use cursors inside pl/pgSQL functions. I tried defining the transaction with Begin work and end work statements, because the documentation says that cursors can only be defined in these blocks. But this does not work. I have the following code :
 
create function sample() returns text as '
declare
    retValue text;
begin work
    declare retCur Cursor for select * from <table name>;
    Fetch 1 in retCur;
    close retCur;
    return ''abc'';
end work;'
language 'plpgsql';
 
When i execute the above it says ' parse error at or near "work" '. I know that in plpgsql function only begin and end keywords define the block, but since I need to retrieve the value one by one from the table I need to do this.
 
Is it possible to do the above? If yes, how can I return the value retrieved from the table, from the function?
 
Regards,
 
Atul 

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

Предыдущее
От: Joel Burton
Дата:
Сообщение: Re: CAST doesn't work :-( (fwd)
Следующее
От: Shay Moreno
Дата:
Сообщение: Re: How to install postgres 7.1 on SuSE 7.1