Re: Recursive function

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Recursive function
Дата
Msg-id 2E5562ED-4B1C-402E-AAAF-32D0BD69025C@gmail.com
обсуждение исходный текст
Ответ на Recursive function  (Juan Daniel Santana Rodés<jdsantana@estudiantes.uci.cu>)
Список pgsql-general
On 22 Nov 2013, at 21:56, Juan Daniel Santana Rodés <jdsantana@estudiantes.uci.cu> wrote:

> Hi everyone...
> I have a problem. I am programming a recursive function in plpgsql language. This function use a cursor and when the
functiontry to call the same function throw a exception that it say me that the cursor is using. 
> My friends how I can to resolve this problem.

Getting that error means that you are effectively trying to run multiple queries simultaneously in the same session. I
don’tthink that’s possible. 

You didn’t tell what you’re trying to achieve, but it sounds to me that you either:
1. forgot to close the cursor for a short (non-recursive) lookup query before recursing to the same/next function,
2. or that you are actually trying to perform  a recursive query.

In case 1 the solution is simple; close the cursor before recursing.
For case 2, you may be able to rewrite your function to not recurse, but instead to use the results of a recursive CTE
toachieve recursion. 

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.



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

Предыдущее
От: Ken Tanzer
Дата:
Сообщение: Re: Getting non_NULL right-side values on a non-matching join?
Следующее
От: Jayadevan M
Дата:
Сообщение: WITH and exclusive locks