From: David Martinez Cuevas <david@estadistica.unam.mx>
To: Neil Burrows <maillist@remo.demon.co.uk>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] A path through a tree
Date: Tue, 12 Jan 1999 10:50:35 -0600 (CST)
Message-ID: <Pine.LNX.3.96.990112104143.9826A-100000@mail> (raw)
In-Reply-To: <000c01be3e38$a1d4a170$c6cb9284@towhee.gssec.bt.co.uk>
Hi Neil.
On Tue, 12 Jan 1999, Neil Burrows wrote:
> Hi,
>
> OK, I have a feeling that this not something that can be done with SQL but I
> may as well give it a shot.
Actually, as you should know, postgresql doesn't have a procedural
language... in this problem it is necessary to use it... but you can use
libpq or any other interface to do it.
> Say you have a table with the following columns:
>
> id int4 NOT NULL UNIQUE
> parent int4
> value varchar(8)
>
Here a is a sample and bad written funtion that can help you.
As you will see I didn't compiled it, and there is a lot of code you
should still write to use it.... it's just an idea:
#include "whatever_you_need";
...
char * look_for_parent ( char *);
function look_for_parent ( char *leaf )
{ if (leaf == NULL) return "This is the root: $leaf";
parent = PQ_EXEC($YOUR_CONN,"select parent from table where values = $leaf")$
print ("\nFor the leaf %s the parent is %s",leaf,parent);
return ( look_for_parent (parent));
}
...
As you can see it pretends to be a C code contaminated with PHP ; )
Good luck
David Martinez Cuevas.mx
"Eat Linux, Drink Linux... SMOKE LINUX".
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-sql@postgresql.org
Cc: david@estadistica.unam.mx, maillist@remo.demon.co.uk
Subject: Re: [SQL] A path through a tree
In-Reply-To: <Pine.LNX.3.96.990112104143.9826A-100000@mail>
References: <000c01be3e38$a1d4a170$c6cb9284@towhee.gssec.bt.co.uk> <Pine.LNX.3.96.990112104143.9826A-100000@mail>
* 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