没有明显的原因我得到了这个错误:
ORA-00942: 表或视图不存在
调试光标在行中设置:
SELECT AMD.MSG_DATE
从以下存储过程:
CREATE OR REPLACE PROCEDURE CTI_MATRIX.AMD_NEEDMSG (v_CRN IN VARCHAR2)
IS
return_flag INTEGER;
row_cnt INTEGER;
number_of_days INTEGER;
var_DATE DATE;
CURSOR ACCNTSEARCH (P_CRN IN VARCHAR2) IS
SELECT AMD.MSG_DATE
FROM TBL_AMD_NEEDMSG AMD
WHERE AMD.PHONE_NUMBER = P_CRN;
BEGIN
OPEN ACCNTSEARCH(v_CRN);
FETCH ACCNTSEARCH INTO var_DATE;
IF ACCNTSEARCH%NOTFOUND
THEN
row_cnt := 0;
ELSE
row_cnt :=1;
END IF;
CLOSE ACCNTSEARCH;
IF (row_cnt = 0)
THEN
INSERT INTO TBL_AMD_NEEDMSG (PHONE_NUMBER, MSG_DATE) VALUES (v_CRN , SYSDATE);
return_flag := 1;
ELSE
SELECT SYSDATE-var_DATE INTO number_of_days FROM dual;
IF (number_of_days>7)
THEN
UPDATE TBL_AMD_NEEDMSG SET MSG_DATE = SYSDATE WHERE PHONE_NUMBER = v_CRN;
return_flag := 1;
ELSE
return_flag := 0;
END IF;
END IF;
COMMIT;
dbms_output.put_line('result='||return_flag );
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
--raise_application_error(-20001,'An error was encountered '||SQLERRM);
END AMD_NEEDMSG;
/
顺便说一句,存储过程是通过以下调用块调用的:
DECLARE
V_CRN VARCHAR2(32767);
BEGIN
V_CRN := '5457648547567';
CTI_MATRIX.AMD_NEEDMSG ( V_CRN );
DBMS_OUTPUT.Put_Line('');
COMMIT;
END;
绝对感到困惑,因为表肯定存在并且以下声明:
SELECT AMD.MSG_DATE
FROM TBL_AMD_NEEDMSG AMD
WHERE AMD.PHONE_NUMBER = '85100000000';
获取没有问题的记录集结果。
请帮忙。