Recursive function w/ hierarchical data

Поиск
Список
Период
Сортировка
От Fran Fabrizio
Тема Recursive function w/ hierarchical data
Дата
Msg-id 3BD7328C.B6D0FD44@mmrd.com
обсуждение исходный текст
Список pgsql-general
Hello,

I have a table like this:

id       parent_id
-----------------------
1        null
2        1
3        1
4        2
5        2
6        2
7        3
etc....

and I'd like to write a function get_children(int) that returned the set
of children for the id passed in as $1.

This will be a recursive function, and I did find a recent newsgroup
post (I think originally from the HACKERS
list) about how to implement recursive SQL functions in Postgres, but
I'm not sure how to go about building the
result set as I go.  Does it involve the creation of a temporary table
to hold the results?

Thanks,
Fran


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Listing users
Следующее
От: "Aasmund Midttun Godal"
Дата:
Сообщение: Re: Function won't compile