Is there an easy way to update composite types inside an array?
Currently I have the following table (I truncated other fields):
CREATE TYPE order_item AS (delivery_date DATE, status INT);
CREATE TABLE demo (id SERIAL PRIMARY KEY, data order_item[]);
I want to update the status
of all order_items
. When it's greater than 1
, all status
should be updated + 1
.
For a table without array field it would be easy:
UPDATE mytab SET complex_col.r = (complex_col).r + 1;
However, I want to do the same inside an array.