我有一个带有以下声明的SP。当我在SQL Developer中单独运行INSERT INTO SELECT查询以获得少量记录时,它运行得很好但是当使用作业从SP运行相同的查询时,我得到“08103:对象不再存在”。能否帮助我理解这个问题背后的原因。
// TEMP_Result_Table是永久表而不是GTT
create or replace PROCEDURE SP_Insert_Matching_Rec
IS
V_SQLCODE NUMBER;
V_SQLERRM VARCHAR2(500);
BEGIN
INSERT INTO TEMP_Result_Table(BillNo,
Contract,
TIN_no,
Message,
run_time)
SELECT
tmp.BillNo,
tmp.Contract,
CASE
WHEN ct.TIN_no IS NOT NULL THEN ct.TIN_no
ELSE
NULL
END AS TIN_no,
'PASS,
SYSDATE
FROM
TEMP_Result_Table tmp
LEFT JOIN
tbl_Contract ct
ON
(
(tmp.Contract = SUBSTR(ct.Contract, -LENGTH(tmp.Contract), LENGTH(tmp.Contract))
OR tmp.Contract = SUBSTR(ct.Old_Contract, -LENGTH(tmp.Contract), LENGTH(tmp.Contract)))
AND tmp.BillNo= SUBSTR(ct.Third_Party_Contract, -(LENGTH(tmp.Contract)), LENGTH(tmp.Contract))
)
OR
(
tmp.BillNo= SUBSTR(ct.Third_Party_Contract, -(LENGTH(tmp.Contract)), LENGTH(tmp.Contract))
);
COMMIT;
EXCEPTION
WHEN others THEN
ROLLBACK;
V_SQLCODE := SQLCODE;
V_SQLERRM := SQLERRM;
INSERT INTO TEMP_Result_Table(MESSAGE,RUN_TIME) VALUES( V_SQLCODE || V_SQLERRM ,SYSDATE);
COMMIT;
END SP_Insert_Matching_Rec;