ORA-30926:无法在源表中获得稳定的行集

时间:2012-08-13 12:52:16

标签: oracle plsql oracle11g plsqldeveloper

我想在取消隐藏后插入数据。该声明需要是一个合并状态网。但是,我收到ora-30926错误,我无法弄清楚如何解决它。

这里是数据表:

------------------------------------------------------------------------------------
|Employee_id | work_experience_1 | work_experience_2 | work_experience_3 | language |
-------------------------------------------------------------------------------------
| 123        |  C&S              |   Deloitte        |         TCS       |     FI   |
| 211        |   E&Y             |   Microsoft       |                   |     FI   |
| 213        |   C&S             |                   |                   |     FI   |
-------------------------------------------------------------------------------------

首先,在输入数据之前,我需要将其取消。

---------------------------------- 
|Employee_id | work_experience   |
----------------------------------
| 123        |   C&S             |
| 123        |   Deloitte        |
| 123        |     TCS           |
| 211        |   E&Y             |
| 211        |   Microsoft       |
| 213        |   C&S             |
----------------------------------

这就是我所做的。插入部分工作正常,但更新部件失败。

MERGE INTO arc_hrcs.user_multi_work_exp work_exp
USING (SELECT user_id, work_experience_lang, work_exp_fi FROM
         (SELECT ext.user_id, tmp_work.employee_id, tmp_work.work_experience_1, tmp_work.work_experience_2, tmp_work.work_experience_3, tmp_work.work_experience_4, tmp_work.work_experience_5, tmp_work.work_experience_6, tmp_work.work_experience_7, tmp_work.work_experience_8, tmp_work.work_experience_9, tmp_work.work_experience_10, tmp_work.work_experience_lang FROM arc_hrcs.hr_extension_data ext
            JOIN aa_work_exp_tmp tmp_work ON tmp_work.employee_id = ext.employee_id) 
            UNPIVOT (work_exp_fi FOR work_code IN (work_experience_1 AS 'a', work_experience_2 AS 'b', work_experience_3 AS 'c', work_experience_4 AS 'd',  work_experience_5 AS 'e', work_experience_6 AS 'f', work_experience_7 AS 'g', work_experience_8 AS 'h', work_experience_9 AS 'i', work_experience_10 AS 'j'))) r
ON (work_exp.user_id = r.user_id AND r.work_experience_lang LIKE '%FI%' )
WHEN NOT MATCHED THEN
     INSERT (work_exp.user_id, work_exp.work_experience_fi)
     VALUES (r.user_id, r.work_exp_fi)
WHEN MATCHED THEN
     UPDATE SET work_exp.work_experience_fi = r.work_exp_fi

我能做些什么让它发挥作用? 干杯和thx提前: - )

2 个答案:

答案 0 :(得分:0)

afaik,MERGE语句需要在ON子句中以及目标表中指定的UNIQUE或PRIMARY KEY列。查看您的数据样本,您可能在源表上遗漏了它们(它们)。

答案 1 :(得分:0)

实质上,USING原因中的查询是一个多行子查询,当它需要是单行子查询时。我会尝试单独运行子查询并尝试修复WHERE原因的逻辑,以便您返回一个唯一的行。

http://blog.mclaughlinsoftware.com/2010/03/05/stable-set-of-rows/