oracle - 在 Oracle 错误中使用内部联接更新语句
问题描述
我有一个在 Sybase 中运行良好的查询,但是当我在 Oracle 上运行它时出现以下错误
update table1
set chk = b.chkakhir
from table1 a
inner join (select substr('0'||inkdwil,-2) wil,substr(chk,-4) site, wil||site chkakhir,wil||'0' chkdcust from table2) b
on a.chk = b.site
where length(a.chk) = 4;
update table1
set chk = b.chkakhir
from table1 a
inner join (select right('0'||inkdwil,2) wil,right(chk,4) site, wil||site chkakhir,wil||'0' chkdcust from table2) b
on a.chk = b.site
where len(a.chk) = 4;
oracle中的查询工作
解决方案
就 Oracle 而言,语法错误。应该是这样的:
UPDATE table1
SET chk =
(SELECT b.chkakhir --> instead of FROM, you have to use SELECT here
FROM table1 a
INNER JOIN (SELECT SUBSTR ('0' || inkdwil, -2) wil,
SUBSTR (chk, -4) site,
wil || site chkakhir,
wil || '0' chkdcust
FROM table2) b
ON a.chk = b.site
WHERE LENGTH (a.chk) = 4);
推荐阅读
- apache-spark - Spark XML API - 标签之间的文本
- javascript - 为什么我的道具带回的是动作功能,而不是日期?
- html - 在复杂形状容器内单击时隐藏/显示面板
- f# - 如何以文雅的方式处理“OPTIONS”请求
- javascript - Framework7 Vue:获取当前视图参数
- junit4 - Junit 测试失败,在 Assert 类中找不到 AssertArrayEquals 方法
- linux - Linux 信号处理程序中的 C++11 同步
- python - 如何拆分训练集和测试集?
- r - R:从文件导入 foo 作为 bar
- file - Xamarin iOS MusicXML 文件在 UIDocumentPickerViewController 中显示为灰色