Raise 错误在带有 Sybase 12.5 客户端库的 Unidac 组件中不起作用

发布于 2024-11-30 18:27:30 字数 900 浏览 4 评论 0原文

我们在 Delphi 10 中使用 Unidac Stored Proc 组件与 Sybase 12.5 驱动程序

在 Sybase proc 中我们引发如下错误,我发现它正在重新运行,但没有显示错误消息。这在 Unidac 中不起作用还是有任何其他问题?

if @number <> null
 begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
   return 1 
 end 

我正在delphi中执行storedproc,如下所示

try 
  ExecProc; 
  except on E:Exception do 
    begin 
     ErrorMsg(EDatabaseError(ExceptObject).Message,0); 
     Exit; 
   end;

,但我们仍然无法捕获异常。

即使我也尝试过如下。

try 
  UniStoredProc.StoredProcName := 'test'; 
  UniStoredProc.ExecProc; 
except 
  on E:EUniError do 
    ShowMessage(E.Message); 
end

相同的代码在 Sybase 15 客户端库上运行良好

我们正在使用 Sybase 15 服务器和 Sybase 12.5 客户端库连接到服务器,这会出现问题吗?早些时候,我们将 BDE 与 Sybase 12.5 客户端库一起使用,因此我们没有遇到任何问题,现在我们在 unidac 中发现了这个问题

We are using Unidac Stored Proc Component in Delphi 10 with Sybase 12.5 drivers

In Sybase proc we are raising error like below,i found it is retruning back but it not showing error message.Isthis not working in Unidac or any other issue?

if @number <> null
 begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
   return 1 
 end 

am executing storedproc in delphi like below

try 
  ExecProc; 
  except on E:Exception do 
    begin 
     ErrorMsg(EDatabaseError(ExceptObject).Message,0); 
     Exit; 
   end;

but still we are not able to catch the exception.

even i have tried like below.

try 
  UniStoredProc.StoredProcName := 'test'; 
  UniStoredProc.ExecProc; 
except 
  on E:EUniError do 
    ShowMessage(E.Message); 
end

Same code is working fine with Sybase 15 Client Libraries

We are using Sybase 15 server and Sybase 12.5 Client libraries to connect to server,will this be a problem? Earlier we are using BDE with Sybase 12.5 Client libraries so we didnt got any issues now we found this issue with unidac

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮生面具三千个 2024-12-07 18:27:30

为了与 null 进行比较,您需要使用 is 运算符,如下所示:

if @number is not null
begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
  return 1 
end 

现在它应该执行 if-then 语句内的代码。

For comparison against null you need to use the is operator like so:

if @number is not null
begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
  return 1 
end 

Now it should execute the code inside the if-then statement.

薆情海 2024-12-07 18:27:30

似乎答案是使用 Sybase 15 客户端而不是 12.5 重新部署应用程序。
由于您已经关闭了“ANSINULL”选项,因此 procs 中的代码肯定会
产生了异常触发。当使用 Sybase 15 时,他们确实这样做了。

侧面思考:让 Sybase 12.5 具有任何连接/客户端范围的配置,
在该版本中关闭并在 Sybase 15 版本中打开“ON”?

如果不是,则这是 Sybase 12.5 的一个错误,该错误已在 Sybase 15 版本中得到纠正(甚至
13号之前,我不知道)。

您不需要重写任何内容,只需重新部署即可。

PS:我从来不喜欢将应用程序部署到客户端库与版本不匹配的服务器,
总是有可能打开一罐蠕虫……显然,情况就是如此。

PS2:当然 UniDAC 使用比 BDE 更多的功能(BDE 是一个带有
“小公分母”方法)触及了 12.5 客户端库的弱点。
另一点是,在 SQL Server(与 Sybase 具有共同遗产)中,raiseerror
severity 参数。并且只有严重性 16+ (AFAIR) 消息才被视为错误 - 也许是 BDE
认为一切都是错误,UniDAC 仅遵循文档。
这是一个非常疯狂的猜测。

Seems the answer is re-deploying the apps using Sybase 15 Client instead of 12.5.
Since you already turned off the "ANSINULL" options, the code in procs certainly would
have produced an exception triggering. And they do, when using Sybase 15.

Side thinking: have Sybase 12.5 have any connection/client-scoped configuration that
was turned off in that release and turned "ON" in Sybase 15 version?

If it's not, it's a bug with Sybase 12.5 that is corrected in Sybase 15 release (or even
before on 13, I don't know).

You don't need to rewrite nothing, just redeploy.

PS: I never liked to deploy app to a server with client libs that don't match on version,
there's always a possibility to open a can of worms... And this is case, apparently.

PS2: Certainly UniDAC uses more functionality than BDE (which was a middleware with a
"minor common denominator" approach) which touched that weak spot on 12.5 client libs.
Another point is that, in SQL Server (which have a common heritage with Sybase), raiseerror have
a severity parameter. And only severity 16+ (AFAIR) messages are considered errors - maybe BDE
decided that everything is a error, where UniDAC is only following documentation.
This a VERY WILD guess.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文