我正在寻找一个存储过程中的链接服务器,以设置一个变量,其结果即使链接服务器抛出错误并将变量设置为任意datetime
也会继续。
我尝试将声明式查询包装在try catch语句中。
BEGIN TRY
SELECT @dttemp = maxdt FROM OPENQUERY(DEV,'SELECT MAX(MODIFIED_DATE) as maxdt FROM ODB.DEV ')
END TRY
BEGIN CATCH
SET @dttemp = cast(-53690 as datetime)
end catch
END CATCH
执行存储过程时,出现此错误提示:
OLE DB provider "OraOLEDB.Oracle" for linked server "DEV" returned message "ORA-12170: TNS:Connect timeout occurred".