在 MERGE 中使用 Oracle CLOB 值

Using Oracle CLOB value inside MERGE

我尝试使用此查询在表之间复制值:

MERGE INTO workflow W
   USING ( 
       SELECT distinct pr.workflow_id, pr.name, pr.description FROM workflow_revision pr, workflow pw WHERE pw.id = pr.workflow_id 
   )WR
   ON ( W.id = WR.workflow_id )
   WHEN MATCHED THEN
   UPDATE SET W.name = WR.name, W.description = WR.description

但它给出了以下错误:ORA-00932: inconsistent datatypes: expected - got CLOB

当从查询中删除 description 列时,它工作正常。这是一个 longtext.

我只是不知道如何解决这个问题。你能帮帮我吗?


由于@eaolson 要求表格的布局,我给出了原始屏幕截图:


在@Lukasz Szozda 提交后我将其作为答案:

MERGE INTO workflow W
USING (
   SELECT workflow_id, name, (CAST (description AS VARCHAR2(4000))) AS description FROM workflow_revision
)WR
ON (W.id = WR.workflow_id)
WHEN MATCHED THEN
UPDATE SET W.name = WR.name, W.description = WR.description;

但正如他也警告的那样;这是一个可接受的答案,只要描述列长度最大 4000(或您在其中提供的值)是。

不需要JOIN:

MERGE INTO workflow W
USING (SELECT workflow_id, name, description FROM workflow_revision)WR
   ON (W.id = WR.workflow_id)
WHEN MATCHED THEN
UPDATE SET W.name = WR.name, W.description = TO_LOB(WR.description);