我是新来的PL/SQL
,我想编写流水线函数来提取付款的通风细节(主表)。这里是代码
CREATE OR REPLACE FUNCTION F_GetImputationsReglement(Pregid Number) RETURN
ImputationsReglementTable PIPELINED IS
BEGIN
DECLARE
ImputationRow Regimputation%ROWTYPE;
type cc is REF CURSOR RETURN ImputationRow%ROWTYPE;
cur0 cc;
CurrentRow ImputationRow%ROWTYPE ;
out_rec ImputationReglementRow := ImputationReglementRow (null,
null,null, null,null);
vquery VARCHAR2(1000);
l_result ImputationReglementRow;
BEGIN
OPEN cur0 FOR
select * from regimputation WHERE regid = pregid;
loop
Fetch cur0 into CurrentRow;
EXIT WHEN cur0%NOTFOUND;
IF CurrentRow.RIMSENS = 'C' OR CurrentRow.RIMSENS IS NULL THEN
IF CurrentRow.facid IS NOT NULL OR (CurrentRow.facid IS NULL AND
CurrentRow.RIMLETTRAGE IS NULL AND CurrentRow.RUBID IS NOT NULL) THEN
out_rec.REGID := CurrentRow.REGID;
out_rec.FACID := CurrentRow.FACID;
out_rec.RIMMT := CurrentRow.RIMMT;
out_rec.FECORDRE := CurrentRow.FECORDRE;
out_rec.RUBID := CurrentRow.RUBID;
PIPE ROW(out_rec);
ELSE
IF CurrentRow.facid IS NULL AND CurrentRow.RIMLETTRAGE is NOT null
and CurrentRow.RUBID IS NOT NULL THEN
vQuery := 'select * from
table(F_GetImputationsReglement(f_getREGID('''|| CurrentRow.RIMLETTRAGE
||''')))';
EXECUTE IMMEDIATE vquery into l_result;
PIPE ROW(l_result);
END IF;
END IF;
END IF;
END LOOP;
CLOSE cur0;
RETURN;
END;
END;
递归的退出条件是:
IF CurrentRow.RIMSENS = 'C' OR CurrentRow.RIMSENS IS NULL THEN
但是当我执行查询
select * from table(f_getimputationsReglement(696213))
我得到错误:
ORA-00603 ORACLE 服务器会话因致命错误而终止
有谁知道它是什么?
谢谢你。