pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Browne <cbbrowne@acm.org>
To: pgsql-admin@postgresql.org
Subject: Re: Recursive use
Date: Fri, 06 Oct 2006 14:04:01 -0400
Message-ID: <60sli1fhim.fsf@dba2.int.libertyrms.com> (raw)
References: <4523B23A.3000506@yahoo.com.br>

burbello3000@yahoo.com.br (Alexander Burbello) writes:
> Hi people,
>
> I need to know if Postgres do recursive search and how can I do!
> I will explain my problem.
>
>
> table COOPERATIVE
>  code_cooperative int
>  code_coo_father int
>
> I can have 3 level by business rules
>
> 1 - Father
> ----- 2 - Children
> --------- 3 - Grandchildren
>
>
> I would like to have a query asking who is father and granfather
> select grandfather, father from COOPERATIVE where COD_COOPERATIVE = 3
>
> Do the Postgres can solve this problem?
> Could anybody help me?

There was a proposal to implement WITH RECURSIVE for PostgreSQL 8.2;
that fell by the wayside.

The task is on the ToDo list:

<http://www.postgresql.org/docs/faqs.TODO.html;
    Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

At present, you may simulate this by writing a pl/pgsql function that
does the recursion in procedural code.
-- 
let name="cbbrowne" and tld="linuxdatabases.info" in name ^ "@" ^ tld;;
http://cbbrowne.com/info/postgresql.html
"Nondeterminism means never having to say you're wrong."  -- Unknown



view thread (9+ messages)  latest in thread

Message-ID: <60sli1fhim.fsf@dba2.int.libertyrms.com>
Permalink:  ../60sli1fhim.fsf@dba2.int.libertyrms.com/
Also on:    postgresql.org/message-id/60sli1fhim.fsf@dba2.int.libertyrms.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: cbbrowne@acm.org
  Subject: Re: Recursive use
  In-Reply-To: <60sli1fhim.fsf@dba2.int.libertyrms.com>
  References: <4523B23A.3000506@yahoo.com.br> <60sli1fhim.fsf@dba2.int.libertyrms.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