我正在尝试通过使用此查询从数据存储中的另一个表收集值来更新表中的一列
UPDATE tablename PT
SET DID = (select distinct(did) from datastore.get_dept_alias
where upper(ltrim(rtrim(deptalias))) = upper(ltrim(rtrim(PT."Dept Descr")))
AND cid = PT.CID)
注:表中的列名与输入的相同
我收到 ORA 01427 错误。对这个问题有什么想法吗?
我试图理解此 ORA 错误的其他帖子
如你看到的here http://forums.devshed.com/oracle-development-96/sql-error-ora-01427-single-row-subquery-returns-more-than-one-row-367953.html
SQL 错误:ORA-01427:单行子查询返回多于一行
这意味着您的子查询
select distinct(did) from datastore.get_dept_alias
where upper(ltrim(rtrim(deptalias))) = upper(ltrim(rtrim(PT."Dept Descr")))
AND cid = PT.CID)
返回不止一行。
那么,你确定distinct (did)
是独特的?看来并非如此。我不建议使用where rownum = 1
因为你不知道将使用哪一个值来更新;除非你使用 ORDER BY。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)