PostgreSQL error code
PostgreSQL error 2202E
2202E is the SQLSTATE PostgreSQL reports for array subscript error, in class 22, Data Exception.
| SQLSTATE | 2202E |
|---|---|
| Condition name | array_subscript_error |
| Class | 22 — Data Exception |
Reproduce it, then fix it
An array slice has to be filled completely. days[1:3] has three positions and the new array has two, so make the slice match the array. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
UPDATE schedules SET days[1:3] = ARRAY[6, 7] WHERE name = 'office' RETURNING days;
UPDATE schedules SET days[1:2] = ARRAY[6, 7] WHERE name = 'office' RETURNING days;