Recursive functions

I want to model and query an n-ary tree.
Is there a way to query recursively?

Something like the PSQL:

WITH RECURSIVE included_parts(sub_part, part) AS (
    SELECT sub_part, part FROM parts WHERE part = 'our_product'
  UNION ALL
    SELECT p.sub_part, p.part
    FROM included_parts pr, parts p
    WHERE p.part = pr.sub_part
)
DELETE FROM parts
  WHERE part IN (SELECT part FROM included_parts);

No, you will have to iterate in the client and query each subsequent level yourself.

2 Likes