oracle无法获得稳定的行,合并更新oracle无法获得稳定的行集

我将展示这个错误的来源是什么.

考虑以下简单示例:

CREATE TABLE A_100(

x_system int,

val int

);

INSERT INTO a_100 values( 1, 100 );

INSERT INTO a_100 values( 2, 200 );

CREATE TABLE B_100(

x_system int,

val int

);

INSERT INTO b_100 values( 1, 1100 );

INSERT INTO b_100 values( 2, 2000 );

INSERT INTO b_100 values( 2, 3000 );

commit;

现在请考虑这个加入:

SELECT *

FROM A_100 a

JOIN B_100 b

ON a.x_system = b.x_system AND a.x_system = 1

;

| X_SYSTEM | VAL | X_SYSTEM | VAL |

|----------|-----|----------|------|

| 1 | 100 | 1 | 1100 |

上面的查询给出了表B_100中的一条唯一记录.如果在合并语句中使用此连接条件,则合并将运行而不会出现任何错误:

MERGE INTO A_100 a

USING B_100 b

ON ( a.x_system = b.x_system AND a.x_system = 1)

WHEN MATCHED THEN UPDATE SET a.val = b.val

;

1 row merged.

现在请考虑以下加入:

SELECT *

FROM A_100 a

JOIN B_100 b

ON a.x_system = b.x_system AND a.x_system = 2

;

| X_SYSTEM | VAL | X_SYSTEM | VAL |

|----------|-----|----------|------|

| 2 | 200 | 2 | 2000 |

| 2 | 200 | 2 | 3000 |

上述连接,来自A_100的一条记录给出了B_100的两条记录.

如果您尝试将MERGE与上述连接条件一起使用,您将获得以下内容:

MERGE INTO A_100 a

USING B_100 b

ON ( a.x_system = b.x_system AND a.x_system = 2)

WHEN MATCHED THEN UPDATE SET a.val = b.val

;

Error report -

ORA-30926: unable to get a stable set of rows in the source tables

Oracle只是简单地说:

The query for one record from the left table returned two values: 2000 and 3000 from the right table. I can not assign two values from the right table to a single scalar field of the left table, this is impossible. Please change the join condition so that it gives only one unique record from the right table for each record in the left table

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值