Re: Recursive pl/pgsql function ...

Поиск
Список
Период
Сортировка
От Markus Schaber
Тема Re: Recursive pl/pgsql function ...
Дата
Msg-id 45334EE8.2030800@logix-tt.com
обсуждение исходный текст
Ответ на Re: Recursive pl/pgsql function ...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hi, Marc,
Hi, Tom,

Tom Lane wrote:
> "Marc G. Fournier" <scrappy@postgresql.org> writes:
>> More then one Record:
>> # select get_next_billing_date(activated, 12) from company_details;
>> ERROR:  control reached end of function without RETURN
>> CONTEXT:  PL/pgSQL function "get_next_billing_date"
> 
> Hm, what PG version is this?  I couldn't duplicate that in HEAD, though
> I did find out that a zero or negative payment_period makes it recurse
> until "stack depth exceeded".

And this is the reason why that function is a nice example where the
recursive design approach is not necessary, and even hurts.

A simple while-Loop will do the same, more efficient, and without any
stack problems.

Btw, it may even be possible to use an explicit formula to calculate
this problem, but date and time calculations are always crazy.

HTH,
Markus
-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org


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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Recursive pl/pgsql function ...
Следующее
От: "Penchalaiah P."
Дата:
Сообщение: hi i want help on levels