我在 Oracle 函数中使用了这个 select 语句,这个输入被传递给 Cursor 进行处理。当我使用该where
子句时,如果我删除它,它会出错“ ORA-14552,无法在查询或 DML 中执行 DDL、提交或回滚”,它工作正常。
Select *
from TableName
where ((EFFECTIVE_DATE<= to_date(to_char(sysdate,'mm-dd-yyyy'),'mm-dd-yyyy'))
and (Effective_End_Date >= SYSDATE OR Effective_End_Date = TO_DATE('01/01/0001','MM/DD/YYYY')))
实际功能:-
Create Function Name(in_name) Return varchar2
Is
Cursor S
IS Select v1,v2,v3 from tablename;
Begin
OPEN S
Loop Fetch S into v_1, v_2, v_3;
Exit when S%NOTFOUND;
if (v_3 is null)
Then For gm_rec in ( Select x,y,z,c from Tablename where
Tablename.x=V_1
and Tablename.y=V_2
)
Loop
RETURN(gm_rec.z)
End Loop;
if (v_3 is not null)
Then For gm_rec1 in ( Select x,y,z,c from Tablename where
Tablename.x=V_1
and Tablename.y=V_2
)
Loop
RETURN(gm_rec1.c)
End Loop;
End IF;
Close S;
Commit;
END
有没有办法克服这个错误?我需要添加 where 子句来过滤掉旧记录。