我在表之間建立了連接。我只是想從一些數據中獲取這些值並將其放入其他列中。但它不起作用。 我該如何重寫查詢? 我想用swkf的值覆蓋wkfc表中的值。Oracle:多表更新=> ORA-01779:無法修改映射到非鍵保存表的列
我知道這是正確的我怎麼才能讓Oracle簡單地做到這一點?
UPDATE (
SELECT --FROM
swkf.swkf_stato_workflow_id "swkf_swkf_stato_workflow_id",
swkf.swkf_data_ini "swkf_swkf_data_ini",
swkf.swkf_versione "swkf_swkf_versione",
swkf.spwkf_stato_pubblico_id "swkf_spwkf_stato_pubblico_id",
swkf.spwkf_data_ini "swkf_spwkf_data_ini",
swkf.spwkf_versione "swkf_spwkf_versione",
--TO
wkfc.swkf_stato_workflow_id "wkfc_swkf_stato_workflow_id",
wkfc.swkf_data_ini "wkfc_swkf_data_ini",
wkfc.swkf_versione "wkfc_swkf_versione",
wkfc.spwkf_stato_pubblico_id "wkfc_spwkf_stato_pubblico_id",
wkfc.spwkf_data_ini "wkfc_spwkf_data_ini",
wkfc.spwkf_versione "wkfc_spwkf_versione"
--
FROM wkfb_stati_workflow swkf, wkf_cronologia wkfc
WHERE twkf_tipo_workflow_id =
(SELECT twkf_tipo_workflow_id
FROM wkf_istanze_workflow wkfi, RET_PUNTI_EROGAZIONE RPUN
WHERE RPUN.PUN_PUNTO_EROGAZIONE_COD = '8001375567' --codice puntero
AND RPUN.PUN_PUNTO_EROGAZIONE_ID = wkfi.ogg_oggetto_id
AND wkfi.tog_tipo_oggetto_id = 'RET_PUN1'
AND wkfi.WKFI_FLAG_ANN = 'N')
AND swkf_descrizione = '(O)Occupato'
AND wkfc.wkfc_cronologia_id = 'ApAJ0qCudNphjLxj'
) a1
set
"wkfc_swkf_stato_workflow_id" = "swkf_swkf_stato_workflow_id" ,
"wkfc_swkf_data_ini" = "swkf_swkf_data_ini" ,
"wkfc_swkf_versione" = "swkf_swkf_versione" ,
"wkfc_spwkf_stato_pubblico_id" = "swkf_spwkf_stato_pubblico_id" ,
"wkfc_spwkf_data_ini" = "swkf_spwkf_data_ini" ,
"wkfc_spwkf_versione" = "swkf_spwkf_versione" ;
這是同樣做如下的,但他必須自行找到值。
UPDATE wkf_cronologia
SET swkf_stato_workflow_id = 'o3gE1tlSdcDIC6FF',
swkf_data_ini = TO_TIMESTAMP ('19-06-2010 18:28:10,556000000','DD-MM-RRRR HH24:MI:SS,FF'),
swkf_versione = 0,
SPWKF_STATO_PUBBLICO_ID = '*1UNICOO',
SPWKF_DATA_INI = TO_TIMESTAMP ('01-01-0001 00:00:00,000000000', 'DD-MM-RRRR HH24:MI:SS,FF'),
SPWKF_VERSIONE = 0
WHERE wkfc_cronologia_id = 'ApAJ0qCudNphjLxj'; --id del record di cronologia da aggiornare (estratto nella prima query)
我沒有看到你的表間的任何聯接標準這個連接。表wkfb_stati_workflow,wkf_cronologia,wkf_istanze_workflow和RET_PUNTI_EROGAZIONE如何關聯? – 2012-02-06 18:09:04
他們不是。我需要從swkf中獲取唯一值並使用它們來更新wkf_cronologia。最好的方法是什麼? – Revious 2012-02-07 11:36:21