Use multiple conflict_target in ON CONFLICT clause

前端 未结 9 790
傲寒
傲寒 2020-11-29 02:25

I have two columns in table col1, col2, they both are unique indexed (col1 is unique and so is col2).

I need at insert into this table, u

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 02:36

    ON CONFLICT is very clumsy solution, run

    UPDATE dupes SET key1=$1, key2=$2 where key3=$3    
    if rowcount > 0    
      INSERT dupes (key1, key2, key3) values ($1,$2,$3);
    

    works on Oracle, Postgres and all other database

提交回复
热议问题