title: how to write a loop condition for to get the sub sub folders name in postgresql
body: <p>I am trying to get the folders name which are in the subfolders.</p>
  <p>Example:</p>
  <pre><code>folder_id  folder_name parent_folder_id
        1             F1      0
        2             F2      1
        3             F3      2
        4             F4      3
  </code></pre>
  <p>Now I am trying to get the f4 name along with the parent folder name like :F1/F2/F3/F4
  I  am getting the parent_folder_id based on folder_id and wrote the loop condition,Here is my function.</p>
  <pre><code>for vrecord in (select parent_folder_id from public.&quot;VOfficeApp_filefolder&quot;
                    where folder_id = ip_folder_id)
  loop        
              
         return query
        select (SELECT array_to_json(array_agg(row_to_json(b))) FROM
               (select folder_name from public.&quot;VOfficeApp_filefolder&quot;
                    where folder_id = v_id)b)as path;
      
  </code></pre>
  <p>end loop;</p>