从sys_refcursor中填充数组

时间:2019-05-21 16:43:30

标签: oracle plsql

我需要调用其他将其传递给数组的过程。是否可以从游标的单列填充数组。并非以下选择查询过于简化。实际包含大量支持特定条件的联接。因此,我想避免在代码中重复查询。

create or replace TYPE personid_array as table of varchar2(9)

  procedure get_by_name (
    i_name                     in varchar2,
    o_person_cursor           out sys_refcursor,
    o_history_cursor          out sys_refcursor
  )as
  v_personid_array personid_array := personid_array();
  begin

    open o_person_cursor for
      select personid, name, age, height from person
      where name = i_name;

    -- I need to populate v_personid_array with only o_person_cursor.personid
    -- This is wrong
    FETCH o_person_cursor BULK COLLECT INTO v_personid_array;

    get_history_by_personids(v_personid_array, o_history_cursor);

  end get_by_name;

0 个答案:

没有答案