oracle-databaseplsqltable-functions

how to corectly call table function in PL/SQL


I have table function which returns table of file names (type t_file_list is table of clob;) from .zip file (in BLOB format) the header is like:

  function get_file_list(
    p_zipped_blob in blob
   ,p_encoding in varchar2 := null
  )
    return t_file_list
  is
  .....
  end;

and I need to select these file names and for each call some procedure, but i cant find way to call function get_file_list correctly, I try this:

  for i in (select * from table(zip_util_pkg.get_file_list(ab_zipped_blob))) 
  loop
    .....
  end loop;

but it gives me some errors like ORA-22905 and PLS-00642. Can someone tell me what I am doing wrong and how to call table function correctly?


Solution

  • No need to use SQL - you can do it entirely in PL/SQL:

    DECLARE
      p_files ZIP_UTIL_PKG.T_FILE_LIST;
    BEGIN
      p_files := zip_util_pkg.get_file_list(ab_zipped_blob);
      FOR i IN 1 .. p_files.COUNT LOOP
        some_procedure( p_files(i) );
      END LOOP;
    END;
    /