批量收集到表类型的对象

时间:2014-05-26 02:28:04

标签: oracle plsql object-type bulk-collect

尝试对对象表使用BULK COLLECT语句ORA-00947: not enough values时出错。

第{1}}行出现错误

from (select jta.nobject_id,

是什么原因?

2 个答案:

答案 0 :(得分:3)

    select * bulk collect
      into l_oWorks
      from (select t_ppw_work(jta.nobject_id,
                   jt.cjobtype_name,                           
                   jta.dactual_start,
                   jta.dactual_finish,
                   st.familiya,
                   jta.ccomment)
              from ppw_jobtype_assign jta
              left join pgts_sotrudnik st
                on jta.nworkerid = st.npgts_sotrudnikkey
              join ppw_jobtype jt
                on jta.njobtype_id = jt.njobtype_key);

您需要先使用定义的对象类型(t_ppw_work)转换结果集。

答案 1 :(得分:0)

您可以改为执行以下操作。

CREATE OR REPLACE EDITIONABLE TYPE  "F_OBJ" AS OBJECT (
Employee_name VARCHAR2(100),
Employee_id VARCHAR2 ( 100 ))

CREATE OR REPLACE EDITIONABLE TYPE  "F_TAB" as table of F_OBJ

create or replace function "fname"
return f_tab
is
 l_f_tab f_tab;

begin
SELECT f_obj(employee_name, employee_id) bulk collect into f_tab from employee_table;
return f_tab;
end;