Recursive queries

Поиск
Список
Период
Сортировка
От Juan Jose Comellas
Тема Recursive queries
Дата
Msg-id 200109211614.f8LGEZk21143@mens.hq.novamens.com
обсуждение исходный текст
Список pgsql-general
I have a database with the following fields:

product_id    INTEGER
parent_id    INTEGER
name        VARCHAR(64)

The idea is that it will store a tree of products and its subproducts. Any
row whose parent_id is NULL will be assumed to be a root product (i.e. top
level).

This means I will need to process recursively, with some sort of reference to
parent_id passing through layers of recursion.

However, I want to save on database queries and do a "SELECT *", then fetch
each row on the results recursively, to build the tree. The idea is to only
have to do one db query.

Does anyone have any idea how this can be done in PostgreSQL? Both Oracle and
DB2 support this with their own proprietary syntax.


--
Juan Jose Comellas
(juanjo@comellas.org)

В списке pgsql-general по дате отправления:

Предыдущее
От: Pete Leonard
Дата:
Сообщение: Postgres 7.1.3 on OpenBSD 2.9?
Следующее
От: bpalmer
Дата:
Сообщение: Re: Postgres 7.1.3 on OpenBSD 2.9?