Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
450 views
in Technique[技术] by (71.8m points)

sql - Oracle: multiple table updates => ORA-01779: cannot modify a column which maps to a non key-preserved table

I've made a Join between tables. I simply want to take the values from some data and put into the other columns. But it doesn't work. How could I rewrite the query? I want to OVERWRITE the values in wkfc table with the values from swkf.

I know it's right how can I make Oracle simply do it?

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"  ;

It's the same of doing as follow, but he have to find the values by itself.

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you want to UPDATE (SELECT ... FROM A INNER JOIN B ON condition) SET A.X = ... then the join condition must constrain all the columns of some uniqueness constraint on B to a single value.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...