admin管理员组文章数量:1277373
How to use SEQ in MERGE?
merge into tab_a tgt using
(Select col1,col2,seq
from tab_a f) src
on
(joinin condition)
when matched then update
set
tgt.seq = src.seq;
It is showing
Sequence number not allowed here
How to achieve this?
How to use SEQ in MERGE?
merge into tab_a tgt using
(Select col1,col2,seq
from tab_a f) src
on
(joinin condition)
when matched then update
set
tgt.seq = src.seq;
It is showing
Sequence number not allowed here
How to achieve this?
Share Improve this question edited Feb 25 at 9:09 Dale K 27.4k15 gold badges58 silver badges83 bronze badges asked Feb 25 at 6:17 TSBTSB 1058 bronze badges2 Answers
Reset to default 1I removed the seq from the source query and added to directly in the update statement, it is working now.
merge into tab_a tgt using
(Select col1,col2
from tab_a f) src
on
(joinin condition)
when matched then update
set
tgt.seq = seq.nextval;
MERGE INTO employees e
USING (SELECT 101 AS emp_code, 'John Doe' AS emp_name FROM dual) src
ON (e.emp_code = src.emp_code)
WHEN MATCHED THEN
UPDATE SET e.emp_name = src.emp_name
WHEN NOT MATCHED THEN
INSERT (emp_id, emp_code, emp_name)
VALUES (emp_seq.NEXTVAL, src.emp_code, src.emp_name);
本文标签: sqlOracle Sequence in MERGE StatementStack Overflow
版权声明:本文标题:sql - Oracle Sequence in MERGE Statement - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741224912a2361675.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论