pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabi@logix-tt.com>
To: pgsql-sql@postgresql.org
Cc: Marc G. Fournier <scrappy@postgresql.org>
Subject: Re: Recursive pl/pgsql function ...
Date: Mon, 16 Oct 2006 11:20:40 +0200
Message-ID: <45334EE8.2030800@logix-tt.com> (raw)
In-Reply-To: <7543.1160969254@sss.pgh.pa.us>
References: <E6008DD5708EE82E0C628C71@ganymede.hub.org>
	<7543.1160969254@sss.pgh.pa.us>

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



view thread (4+ messages)

Message-ID: <45334EE8.2030800@logix-tt.com>
Permalink:  ../45334EE8.2030800@logix-tt.com/
Also on:    postgresql.org/message-id/45334EE8.2030800@logix-tt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: schabi@logix-tt.com, scrappy@postgresql.org
  Subject: Re: Recursive pl/pgsql function ...
  In-Reply-To: <45334EE8.2030800@logix-tt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox