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