Re: Recursive pl/pgsql function ... - Mailing list pgsql-sql

From Markus Schaber
Subject Re: Recursive pl/pgsql function ...
Date
Msg-id 45334EE8.2030800@logix-tt.com
Whole thread Raw
In response to Re: Recursive pl/pgsql function ...  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: Recursive pl/pgsql function ...
Next
From: "Penchalaiah P."
Date:
Subject: hi i want help on levels