Sybase 更新表时出错

发布于 2024-09-14 19:49:24 字数 568 浏览 4 评论 0原文

我在 Sybase 表上发出 UPDATE 语句,但收到以下错误:

消息 325,级别 18,状态 4: 服务器“dev”,第 1 行: Adaptive Server 找不到该语句的合法查询计划。如果是摘要 Plan是强制执行查询计划,检查其与查询的对应关系。如果不, 请联系 Sybase 技术支持。

这是我的更新声明。

 Update TABLE1 SET SAMPLECOL = (
   Select
   TABLE2.SAMPLECOL
   from TABLE2
   where
   TABLE2.COMMON_ID = TABLE1.COMMON_ID
 )
 where
 TABLE1.TABLE1_ID in (
   Select
   TABLE1.TABLE1_ID
   from TABLE1
   inner join TABLE2
   on TABLE1.COMMON_ID = TABLE2.COMMON_ID
   where TABLE1.SAMPLECOL = ''
 )

任何见解将不胜感激。

I am issuing an UPDATE Statement on a Sybase table but I am getting the below error:

Msg 325, Level 18, State 4:
Server 'dev', Line 1:
Adaptive Server finds no legal query plan for this statement. If an Abstract
Plan is forcing the query plan, check its correspondence to the query. If not,
please contact Sybase Technical Support.

Here is my UPDATE Statement.

 Update TABLE1 SET SAMPLECOL = (
   Select
   TABLE2.SAMPLECOL
   from TABLE2
   where
   TABLE2.COMMON_ID = TABLE1.COMMON_ID
 )
 where
 TABLE1.TABLE1_ID in (
   Select
   TABLE1.TABLE1_ID
   from TABLE1
   inner join TABLE2
   on TABLE1.COMMON_ID = TABLE2.COMMON_ID
   where TABLE1.SAMPLECOL = ''
 )

Any insights will be greatly appreciated.

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

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

发布评论

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

评论(2

妄司 2024-09-21 19:49:24

我认为问题在于您正在使用可能返回多个值的内容设置列 SAMPLECOL 。尝试执行此操作并将结果发布回此处:(

Update TABLE1 SET SAMPLECOL = (
   set rowcount 1
   Select 
   TABLE2.SAMPLECOL
   from TABLE2
   where
   TABLE2.COMMON_ID = TABLE1.COMMON_ID
   set rowcount 0
 )

这将仅选择一行记录,您的逻辑可能无法基于此工作,但是就您收到的错误而言,我确信与此相关)。再次尝试并让我们知道结果。

I THINK the problem is that you are setting the column SAMPLECOL with something which could return multiple values. Try doing this and post the result back here:

Update TABLE1 SET SAMPLECOL = (
   set rowcount 1
   Select 
   TABLE2.SAMPLECOL
   from TABLE2
   where
   TABLE2.COMMON_ID = TABLE1.COMMON_ID
   set rowcount 0
 )

(this will select only one row record and your logic might not work based on this, however as far as the error you are getting I am sure is related to this). Again try it and let us know the outcome.

☆獨立☆ 2024-09-21 19:49:24

尝试代替;

update TABLE1
   set SAMPLECOL = T2.SAMPLECOL
  from TABLE1 T1, TABLE2 T2
 where T1.COMMON = T2.COMMON
   and isnull(T1.SAMPLECOL, '') = ''

try instead;

update TABLE1
   set SAMPLECOL = T2.SAMPLECOL
  from TABLE1 T1, TABLE2 T2
 where T1.COMMON = T2.COMMON
   and isnull(T1.SAMPLECOL, '') = ''
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文