Re: Recursive pl/pgsql function ...

From: Markus Schaber <schabi(at)logix-tt(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Subject: Re: Recursive pl/pgsql function ...
Date: 2006-10-16 09:20:40
Message-ID: 45334EE8.2030800@logix-tt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi, Marc,
Hi, Tom,

Tom Lane wrote:
> "Marc G. Fournier" <scrappy(at)postgresql(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Penchalaiah P. 2006-10-16 14:47:01 hi i want help on levels
Previous Message Marc G. Fournier 2006-10-16 06:16:06 Re: Recursive pl/pgsql function ...