问题描述:目前有两台oracle数据库服务器的数据需要交互,使用的是datalink的形式进行,但是由于其中一台数据库服务器(其他厂家的)经常因为网络问题,导致连接不上或者连接超时,导致调用存储过程进行相关数据交互操作的时候,出现异常了。 目前,希望通过ORACLE的异常处理,来捕获这个异常,当出现这个异常的时候,将数据进行回滚操作,来保证数据的一致性,但是,不知道该捕获哪种异常,该怎么操作,求大神指点!(打算在进行数据操作前,先使用连接串查询下数据,判断能否正常连接,如果没有异常则直接对数据进行操作,但是不知道怎么写)
declare
v_ErrorCode NUMBER; -- Variable to hold the error message code
v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
i number;
begin
-- Test statements here
select count(*) into i from psbob_realtime.ln@fzems ;
Exception
when Timeout_on_resource then
--do something
when others then
v_ErrorCode := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
dbms_output.put_line(v_ErrorCode || '::'||v_ErrorText);
end;用上面的来捕获异常捕获不了 ,求大神指点 ,感激不尽!
declare
v_ErrorCode NUMBER; -- Variable to hold the error message code
v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
i number;
begin
-- Test statements here
select count(*) into i from psbob_realtime.ln@fzems ;
Exception
when Timeout_on_resource then
--do something
when others then
v_ErrorCode := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
dbms_output.put_line(v_ErrorCode || '::'||v_ErrorText);
end;用上面的来捕获异常捕获不了 ,求大神指点 ,感激不尽!
解决方案 »
- 如何在ORACLE中定义一个函数,固定返回一个字符串如('0501','0502','0503','0507','0542','0543')
- oracle自定义function如果异常返回值是什么?
- 为什么oracle游标没有值?????
- [500分]怎么实现oracle单向数据同步A主机上的数据库--->B主机上的数据库?要求达到每秒更新!
- 问个简单的SQL语句
- 求SQL
- Oracle Service Bus的For Each用法
- 如何实现不同用户下的两个表的数据同步?
- ██████快救救我啊。在线等待。我被Oracle整惨了。██████
- 在Win2K Server安装Oracle817时,没有安装数据库,后在创建数据库时出现"ORA-12560:TNS:协议适配器错误"...
- 怎么都没有 软件销售 职位?
- 大神们oracl 中显示两个时间段中的所有整点时间呢
declare
v_errorcode number; -- variable to hold the error message code
v_errortext varchar2(200); -- variable to hold the error message text
i number;
begin select count(*) into i from psbob_realtime.ln@fzems;
dbms_output.put_line('总数为:'||i);
exception
when others then
v_errorcode := sqlcode;
v_errortext := substr(sqlerrm, 1, 200);
dbms_output.put_line(v_errorcode || '::'||v_errortext);
end;
num number;
BEGIN
BEGIN
EXECUTE IMMEDIATE 'select count(*) from dual@os_ns';
dbms_output.put_line('ok');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('timeout');
raise;
END;
DBMS_OUTPUT.put_line('continue....');
END;