Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id C4B3F9FB411 for ; Fri, 6 Oct 2006 15:33:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 56767-03 for ; Fri, 6 Oct 2006 18:32:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from news.hub.org (news.hub.org [200.46.204.72]) by postgresql.org (Postfix) with ESMTP id 13DEF9FB29F for ; Fri, 6 Oct 2006 15:32:29 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id k96IWQ1K042517 for ; Fri, 6 Oct 2006 15:32:26 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id k96I40RP037222 for pgsql-admin@postgresql.org; Fri, 6 Oct 2006 15:04:00 -0300 (ADT) (envelope-from news) From: Chris Browne X-Newsgroups: pgsql.admin Subject: Re: Recursive use Date: Fri, 06 Oct 2006 14:04:01 -0400 Organization: cbbrowne Computing Inc Lines: 38 Message-ID: <60sli1fhim.fsf@dba2.int.libertyrms.com> References: <4523B23A.3000506@yahoo.com.br> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) Cancel-Lock: sha1:N0SsTHvYzeaE4jeTpRJLLfTNFKU= To: pgsql-admin@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.274 tagged_above=0 required=5 tests=INFO_TLD, UNPARSEABLE_RELAY X-Spam-Level: * X-Archive-Number: 200610/49 X-Sequence-Number: 23352 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: 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