Oracle — WITH CLAUSE => MERGE? (Syntax error, )

£可爱£侵袭症+ 提交于 2019-12-01 02:58:29

You can't use the WITH clause anywhere but in a SELECT statement. See the documentation here.:

You can specify this clause in any top-level SELECT statement and in most types of subqueries.

So, you can do something like this (11g tested):

MERGE INTO animalia d
USING (WITH X AS 
       (SELECT  'moo' AS COW, 'woof' AS CAT, 
                (SELECT MAX( DECIBELS ) 
                   FROM ANIMALIA 
                  WHERE COW = 'moo' ) AS DECIBELS
          FROM DUAL )
       SELECT * FROM X) q ON (1 = 1)
 WHEN MATCHED THEN UPDATE SET d.cow = q.cow||' and more';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!