2017-06-28 5 views
1

私はon conflictステートメントを使用してアップアップを行っていますが、エラーが発生します:Syntax error near to line 58: ON CONFLICT (id_producto_final) DOコンフリクトpostgresql文はジョインで動作しますか?

クエリ文は次のとおりです。

 Insert into table1 (id, value1, description, isactivated) 
    select a.id, b.value1, c.description, d.isactivated 
    from tableA as a 
    left join tableB as b on b.id=a.id1 
    left join tableC as c on c.id=a.id2 
    left join tableD as d on d.id=a.id3 
    ON CONFLICT (id) DO UPDATE SET isactivated= EXCLUDED.isactivated 

それはdo nothingで動作していないどちらも、そうexcluded tableエラーではありません。だから私はおそらくエラーソースに参加しているかもしれないと推測していますが、私は理由も知りません。

誰でも手助けできますか?

+2

から始まる解釈され –

+0

@VaoTsun 9.4.10 – Maik

答えて

3

https://www.postgresql.org/docs/9.5/static/sql-insert.html

ON CONFLICT can be used to specify an alternative action to raising a unique constraint or exclusion constraint violation error. (See ON CONFLICT Clause below.)

https://www.postgresql.org/docs/9.4/static/sql-insert.html - いいえ、そのようなオプション。 ON CONFLICTは..?あなたは9.5の後にそれを実行しない9.5

https://www.postgresql.org/docs/9.5/static/release-9-5.html

Major enhancements in PostgreSQL 9.5 include:

Allow INSERTs that would generate constraint conflicts to be turned into UPDATEs or ignored

+0

おかげバオ! 9.4の代替手段は何ですか? – Maik

+0

例えば 'do ... except when ... then update ...'、またはCTE –

+0

はここにいくつかの例があります:https://stackoverflow.com/q/1109061/5315974 –

関連する問題