Database 甲骨文翻译博士后

Database 甲骨文翻译博士后,database,oracle,postgresql,syntax,Database,Oracle,Postgresql,Syntax,如何将此Postgres语句解析为Oracle 11g UPDATE teams as new SET counter=old.counter, task_counter=old.task_counter FROM teams as old WHERE new.is_old=0 AND old.is_old=1 AND new.name=old.name AND new.county=old.county; 提前谢谢 您似乎希望使用联接执行更新,即upd

如何将此Postgres语句解析为Oracle 11g

UPDATE teams as new 
  SET counter=old.counter, 
      task_counter=old.task_counter 
FROM teams as old
WHERE new.is_old=0 
  AND old.is_old=1 
  AND new.name=old.name 
  AND new.county=old.county;

提前谢谢

您似乎希望使用联接执行更新,即
update。。。从
。这似乎不受直接支持,但可以使用带有子查询的
UPDATE
来完成

见:


这假设子选择只会为每个名称/县/旧组合返回一行。

Oracle的一种简便技术是对这些棘手的更新使用合并

Merge into teams new 
From (
  Select counter,
         task_counter
  From   teams 
  Where  is_old = 1) old
On (new.is_old = 0          and
    new.name   = old.name   and
    new.county = old.county   )
when matched then update
set counter      = old.counter and
    task_counter = old.task_counter

@莱奥拉:你为什么认为这是一个触发器?
Merge into teams new 
From (
  Select counter,
         task_counter
  From   teams 
  Where  is_old = 1) old
On (new.is_old = 0          and
    new.name   = old.name   and
    new.county = old.county   )
when matched then update
set counter      = old.counter and
    task_counter = old.task_counter