我想在取消透视后插入数据。该语句需要是一个合并语句。但是,我收到 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
我该怎么做才能让它工作?提前干杯和谢谢:-)