Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE treeDown(INTEGER)
  2. LANGUAGE plpgsql
  3. AS $$
  4. DECLARE
  5. cur_childs CURSOR FOR select * from TreeRelation where von = $1 AND from < to;
  6. rec RECORD;
  7. BEGIN
  8. FOR rec IN cur_childs LOOP
  9. CALL treeDown(rec.to); -- seems to die here
  10. RAISE NOTICE '% is a child from %', rec.to, $1;
  11. end loop;
  12. END;
  13. $$;
  14.  
  15. ...
  16. FOR rec IN (SELECT *
  17. FROM treerelation
  18. WHERE ...) LOOP
  19. ...
  20.  
  21. -- 3 is our start node in this case
  22. WITH RECURSIVE test(s) AS (
  23. select to from TreeRelation where from = 3 AND from < to
  24. UNION
  25. select to from test, TreeRelation where from = test.s AND from < to
  26. ) select * from test;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement