当我运行此查询时:
MERGE INTO AMDW.DIMSECURITY_08052018 OUTER_TAB
USING (Select DISTINCT DS.SECURITYKEY,DCQ.currencycode From AMDW.DIMSECURITY_08052018 DS inner join AMDW.FACTTRANSACTION FT
on DS.securitykey =FT.SECuritykey inner join AMDW.DIMELEMENTARYTRANSACTIONTYPE DETT on DETT.ELEMENTARYTRANSACTIONTYPEKEY=FT.ELEMENTARYTRANSACTIONTYPEKEY
inner join AMDW.DIMCURRENCY DCQ on DCQ.CURRENCYKEY = FT.QUOTATIONCURRENCYKEY
where legacyholdtype='FRWD' and DS.WISCURRENT=1 and DS.wlastupdatetimestamp <= to_date('09-02-2018','DD-MM-YYYY') and FT.NOMINALFACTOR=1 and
upper(DETT.ELEMENTARYTRANSACTIONCATEGORY) <> 'MATURITY AND EXERCISE' ) INNER_TAB
ON ( (OUTER_TAB.SECURITYKEY = INNER_TAB.SECURITYKEY))
WHEN MATCHED
THEN
UPDATE SET OUTER_TAB.LegacyBUYQUOTATIONCURRENCY = INNER_TAB.currencycode ;
这是一个错误:
[错误]执行(10:46):ORA-30926:无法在源表中获得稳定的行集。
我想更新重复的行。
SELECT SECURITYKEY,currencycode, count(*)
FROM (
Select DS.SECURITYKEY,DCQ.currencycode From AMDW.DIMSECURITY_08052018 DS inner join AMDW.FACTTRANSACTION FT
on DS.securitykey =FT.SECuritykey inner join AMDW.DIMELEMENTARYTRANSACTIONTYPE DETT on DETT.ELEMENTARYTRANSACTIONTYPEKEY=FT.ELEMENTARYTRANSACTIONTYPEKEY
inner join AMDW.DIMCURRENCY DCQ on DCQ.CURRENCYKEY = FT.QUOTATIONCURRENCYKEY
where legacyholdtype='FRWD' and DS.WISCURRENT=1 and DS.wlastupdatetimestamp <= to_date('09-02-2018','DD-MM-YYYY') and FT.NOMINALFACTOR=1 and
upper(DETT.ELEMENTARYTRANSACTIONCATEGORY) <> 'MATURITY AND EXERCISE'
)
group by SECURITYKEY,currencycode
having count(*) > 1
结果:
SECURITYKEY currencycode count
31243412 USD 2
31243422 USD 2
31243426 AUD 2
31243324 EUR 3
31243338 USD 2
31243336 GBP 2
31243366 BRL 2
31243423 GBP 2
31243346 GBP 2
31243429 EUR 2
31243343 GBP 2
31243425 USD 2
31243431 NZD 2
31243333 USD 3
31243330 GBP 2
31243341 USD 2
31243342 GBP 2
31243348 GBP 2
31243328 GBP 2
31243337 GBP 2
31243433 AUD 2
31243434 NZD 2
31243367 BRL 2
31243428 NZD 2
31243427 EUR 2
31243432 EUR 2
31243347 USD 2