简体   繁体   中英

how to update multiple select row in db2

i have problem to update the multiple selection row in table.This is my query. Anyone know what the problem?.

--update mvp_employer--
set (MEI_EMP_CAT_CD) = 
(select case when a.MEI_EMP_CAT_CD is not null then a.MEI_EMP_CAT_CD else b.MEI_EMP_CAT_CD end MEI_EMP_CAT_CD
from (
select MEI_ROC_NO,MEI_DOC_TYP_CD,MEI_EMP_CAT_CD from jimd2.mvp_employer
where mei_roc_no in (select mei_roc_no from MVP_EMPLOYER
WHERE MEI_DOC_TYP_CD IN ('632','999')
group by mei_roc_no having count(*) >1)
and MEI_DOC_TYP_CD IN ('632')
order by mei_roc_no, mei_doc_typ_cd ) a
FULL JOIN
(
select MEI_ROC_NO,MEI_DOC_TYP_CD,MEI_EMP_CAT_CD from jimd2.mvp_employer
where mei_roc_no in (select mei_roc_no from MVP_EMPLOYER
WHERE MEI_DOC_TYP_CD IN ('632','999')
group by mei_roc_no having count(*) >1)
and MEI_DOC_TYP_CD ='999'
order by mei_roc_no, mei_doc_typ_cd ) b 
on a.mei_roc_no = b.mei_roc_no
) 
where  MEI_DOC_TYP_CD IN ('632') 
and mei_roc_no ='AS0002107-A'

ERROR:- Error code -811, SQL state 21000: DB2 SQL Error: SQLCODE=-811, SQLSTATE=21000, SQLERRMC=null, DRIVER=3.53.95

You should probably read the error message:

SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row

So your query returns more rows and DB2 does not know which one to assign to your set clause. Correct your query - maybe add a distinct (depends on your needs) - and try again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM