我在使用Oracle PL / SQL中的函数时遇到了麻烦。
以下是代码:
create or replace FUNCTION FX_A (IVI NUMBER)
RETURN ListadoStrings
AS
datos ListadoStrings;
dato VARCHAR2(4000);
idx NUMBER;
BEGIN
datos := ListadoStrings();
BEGIN
FOR prog IN (
SELECT TCPR.DES
FROM TIVI TVIS
JOIN TICPR TCPR ON (TCPR.PRO = TVIS.PRO AND TCPR.CAT = TVIS.CAT AND TCPR.TIP = TVIS.TIP)
WHERE TVIS.IVI = IVI
) LOOP
datos.extend;
datos( datos.count ) := prog;
END LOOP;
END;
BEGIN
FOR tarea IN (
SELECT TTAR.DES
FROM TIVI TVIS
JOIN TITAR TBTAR ON TBTAR.IVI = TVIS.IVI
JOIN TMTAR TTAR ON TTAR.ITAR = TBTAR.ITAR
WHERE TVIS.IVI = IVI
) LOOP
datos.extend;
datos( datos.count ) := tarea;
END LOOP;
END;
return datos;
END FX_A;
当我运行此脚本时,我得到了响应:
功能FX_DATOSVISITA已编译
错误:检查编译器日志
在编译器日志中,我看到:
错误(17,13):PL / SQL:语句被忽略
错误(17,37):PLS-00382:表达式类型错误
错误(30,13):PL / SQL:语句被忽略
错误(30,37):PLS-00382:表达式类型错误
受影响的线路都是" END LOOP;"线。
你能帮帮我吗? 谢谢!编辑1:
好的,现在我没有任何错误,但函数返回NOTHING:
create or replace FUNCTION FX_A (IVI NUMBER)
RETURN ListadoStrings
AS
datos ListadoStrings;
dato VARCHAR2(4000);
idx NUMBER;
BEGIN
datos := ListadoStrings();
BEGIN
FOR prog IN (
SELECT TCPR.DES as des
FROM TIVI TVIS
JOIN TICPR TCPR ON (TCPR.PRO = TVIS.PRO AND TCPR.CAT = TVIS.CAT AND TCPR.TIP = TVIS.TIP)
WHERE TVIS.IVI = IVI
) LOOP
DBMS_OUTPUT.PUT_LINE(prog.des );
datos.extend;
datos( datos.count ) := prog.des;
END LOOP;
END;
BEGIN
FOR tarea IN (
SELECT TTAR.DES as des
FROM TIVI TVIS
JOIN TITAR TBTAR ON TBTAR.IVI = TVIS.IVI
JOIN TMTAR TTAR ON TTAR.ITAR = TBTAR.ITAR
WHERE TVIS.IVI = IVI
) LOOP
DBMS_OUTPUT.PUT_LINE(tarea.des );
datos.extend;
datos( datos.count ) := tarea.des;
END LOOP;
END;
return datos;
END FX_A;
我可以看到DBMS_OUTPUT.PUT_LINE(tarea.des)的结果;在控制台中,但该功能的返回仅为" ART_MOVIL.VISITA_DATOS("
你能帮忙吗?
答案 0 :(得分:0)
替代实施。将批量收集环替换为本地收集,然后将它们混合在一起。设置操作FTW!
create or replace FUNCTION FX_A (IVI NUMBER)
RETURN ListadoStrings
AS
datos1 ListadoStrings;
datos2 ListadoStrings;
datos ListadoStrings;
BEGIN
datos := ListadoStrings();
SELECT TCPR.DES
bulk collect into datos1
FROM TIVI TVIS
JOIN TICPR TCPR ON (TCPR.PRO = TVIS.PRO AND TCPR.CAT = TVIS.CAT AND TCPR.TIP = TVIS.TIP)
WHERE TVIS.IVI = IVI;
SELECT TTAR.DES
bulk collect into datos2
FROM TIVI TVIS
JOIN TITAR TBTAR ON TBTAR.IVI = TVIS.IVI
JOIN TMTAR TTAR ON TTAR.ITAR = TBTAR.ITAR
WHERE TVIS.IVI = IVI;
datos := datos1 multiset union all datos2;
return datos;
END FX_A;