创建1个过程
CREATE OR REPLACE PROCEDURE sp_tst_job_for_dblink
AS
cnt NUMBER;
sss varchar2(400);
BEGIN
SELECT COUNT(*) INTO cnt FROM test22@tst_db;
INSERT INTO test(slog1,slog2) VALUES(to_char(cnt),to_char(SYSDATE, 'yyyy-mm-dd hh24:mi:ss ')|| '==> sp_tst_job_for_dblink ');
COMMIT;
EXCEPTION
WHEN OTHERS THEN
sss:=SQLERRM;
INSERT INTO test(slog1,slog2) VALUES(sss,to_char(SYSDATE, 'yyyy-mm-dd hh24:mi:ss ')|| '==> sp_tst_job_for_dblink ');
COMMIT;
END sp_tst_job_for_dblink;
/
单独exec sp_tst_job_for_dblink;很顺利,结果塞进去了:
57430610 2011-11-14 16:40:03==> sp_tst_job_for_dblink
然后用job调用:
var jobnum number;
begin
DBMS_JOB.submit (:jobnum, 'sp_tst_job_for_dblink; ',SYSDATE,null);
commit;
end;
/
结果就过程就报错了:
ORA-12154: TNS:could not resolve the connect identifier specified 2011-11-14 16:52:22==> sp_tst_job_for_dblink
谁知道什么原因?
------解决方案--------------------
- SQL code
create synonym test22 for test22@tst_db;