2 つの値を返す select ステートメントの出力で単一のテーブルを更新しようとしています。1 つはテーブルで更新する必要がある accountid で、もう 1 つは更新する必要がある情報です。
Here is my select statement
select CTP.CARETEAMPATIENTID, O.ORGANIZATIONID
from acts.careteampatient ctp,
ods.member m,
ods.supplierorganization so,
ods.MASTERSUPPLIERSUPPLIERRELATION mssr,
ods.INSURANCEORGSUPPLIERRELATION IOSR,
ods.INSURANCEORGANIZATION IO,
acts.organization o
where ctp.accountorgid is null
and m.primarymemberplanid = ctp.primarymemberplanid
and SO.AHMSUPPLIERID = M.AHMSUPPLIERID
and mssr.SUPPLIERID = so.SUPPLIERORGID
AND iosr.SUPPLIERID = so.SUPPLIERORGID
AND io.INSURANCEORGID = iosr.INSURANCEORGID
and io.processingmodecd = 'P'
and so.usagemnemonic = 'P'
and O.ODSACCOUNTID = IO.INSURANCEORGID
and O.ACCOUNTFLG = 'Y'
に沿って何かをしたい
update careteampatient
from (select CTP.CARETEAMPATIENTID patientid, O.ORGANIZATIONID orgid
from acts.careteampatient ctp,
ods.member m,
ods.supplierorganization so,
ods.MASTERSUPPLIERSUPPLIERRELATION mssr,
ods.INSURANCEORGSUPPLIERRELATION IOSR,
ods.INSURANCEORGANIZATION IO,
acts.organization o
where ctp.accountorgid is null
and m.primarymemberplanid = ctp.primarymemberplanid
and SO.AHMSUPPLIERID = M.AHMSUPPLIERID
and mssr.SUPPLIERID = so.SUPPLIERORGID
AND iosr.SUPPLIERID = so.SUPPLIERORGID
AND io.INSURANCEORGID = iosr.INSURANCEORGID
and io.processingmodecd = 'P'
and so.usagemnemonic = 'P'
and o.odsaccountid = io.insuranceorgid
and o.accountflg = 'Y') b
set a.accountorgid = b.orgid
where a.careteampatientid = b.patientid
ここに私も試したマージがあります
merge into careteampatient a
using (select CTP.CARETEAMPATIENTID patientid, O.ORGANIZATIONID orgid
from acts.careteampatient ctp,
ods.member m,
ods.supplierorganization so,
ods.MASTERSUPPLIERSUPPLIERRELATION mssr,
ods.INSURANCEORGSUPPLIERRELATION IOSR,
ods.INSURANCEORGANIZATION IO,
acts.organization o
where ctp.accountorgid is null
and m.primarymemberplanid = ctp.primarymemberplanid
and SO.AHMSUPPLIERID = M.AHMSUPPLIERID
and mssr.SUPPLIERID = so.SUPPLIERORGID
AND iosr.SUPPLIERID = so.SUPPLIERORGID
AND io.INSURANCEORGID = iosr.INSURANCEORGID
and io.processingmodecd = 'P'
and so.usagemnemonic = 'P'
and o.odsaccountid = io.insuranceorgid
and o.accountflg = 'Y') b
on a.careteampatientid = b.patientid
when matched then
update
set a.accountorgid = b.orgid
これは機能しておらず、アイデアが新鮮ではないため、どんな助けも素晴らしいでしょう。ありがとう