I have a table where I insert values using the AWS RDS Data API, more specifically BatchExecuteStatement.
This batch insert ends up as a series of insert statements sent to a PosgreSQL 10.7 DB. I don't have a lot of control over the iteration unless I want to call the non-batch API, which would be a bad idea.
So within the limitations of this API, I would like to:
- Upsert (update if the row already exists, to avoid violating the primary key constraint)
- Skip inserting fields that violate a foreign key constraint since I don't really need them.
I tried this, but it didn't work:
insert into my_table(item_id, label_id) values(:item_id, :label_id)
on conflict(item_id, label_id)
do update set
item_id = :item_id,
label_id = :label_id
on conflict fk_label_id do nothing
=>
ERROR: syntax error at or near "on"
I also tried:
on conflict(item_id, label_id, on constraint fk_label_id)
Same result.
I'm not sure what to do now