gpt4 book ai didi

oracle - 批量收集到表类型的对象

转载 作者:行者123 更新时间:2023-12-05 09:23:11 25 4
gpt4 key购买 nike

尝试使用 BULK COLLECT 语句 ORA-00947: not enough values for objects of objects 时出现错误。

错误发生在行 from (select jta.nobject_id,

CREATE OR REPLACE TYPE "T_PPW_WORK"  as object                                     
(
nObjectKey number,
cJobType varchar2(500),
dPlanStart date,
dPlanEnd date,
cExecutor varchar2(500),
cComment varchar2(4000)
)

CREATE OR REPLACE TYPE "T_PPW_WORK_TABLE" as table of T_PPW_WORK;


function getPlannedOverdueJobs(in_nPlanKey number) return T_PPW_WORK_TABLE is
l_oWorks T_PPW_WORK_TABLE;
l_oWork T_PPW_WORK;
begin

select * bulk collect
into l_oWorks
from (select 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);
return l_oWorks;
end getPlannedOverdueJobs;

这是什么原因?

最佳答案

    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) 转换结果集。

关于oracle - 批量收集到表类型的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23861927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com