I have the following table
| ID | Seq No|
+++++++++++++++
| 1 | 12345 |
| 2 | 12345 |
| 3 | 12345 |
| 4 | 12345 |
| 5 | 12345 |
Both the columns are primary key values.
Here I need to increment the value by 1 for ID values greater than 2.
Following is the query I tried to execute
Update tblname
set id = id + 1
where id > 2 and seq_no = 12345
I got the following error when executing the command
ERROR: duplicate key value violates unique constraint "tblname"
DETAIL: Key (id, seq_no)=(3, 12345) already exists.
How do I solve this issue.
PS: As a workaround, I tried adding 10 to the ID value and again subtracted 9 from the ID value.