Advertisement
Maks140888

Untitled

Jun 1st, 2022
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.61 KB | None | 0 0
  1. create or replace function find_first_childs (obj_x VARCHAR2)
  2. return objects_below as first_childs objects_below;
  3. begin
  4.     select LPAD(' ', 5*level)||objects.name
  5.     BULK COLLECT into first_childs
  6.     FROM objects JOIN object_types USING (object_type_id)
  7.     where level < (
  8.         select level from objects where name = obj_x
  9.         start with parent_id is null CONNECT by prior object_id = parent_id
  10.         ) + 1
  11.     START WITH objects.name = obj_x
  12.         CONNECT by prior objects.object_id = objects.parent_id;
  13.    
  14.     return first_childs;
  15. end;
  16.  
  17. select * from find_first_childs('ін-94-1');
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement