Ahh I found what I was doing wrong, there was a rogue value being returned causing to infinite loop. Its fixed now. 
Creating that script you recommended set my thinking process straight.
many thanks
Mark
On Saturday 10 February 2001 08:42, Tom Lane wrote:
> mark proctor <m.proctor@bigfoot.com> writes:
> > However if I put the PERFORM line back in to create a recursive
> > function it just goes on forever, and I only have 6 nodes.
>
> Hm.  There may be a bug here, or maybe you're still confused... but I'm
> not eager to reverse-engineer your table declarations and data from this
> sketch.  Would you mind providing a complete example, ie a SQL script to
> reproduce the problem starting from an empty database?
>
>             regards, tom lane