Questions about setting an array element value outside of the update

From: Maxim Boguk <maxim(dot)boguk(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Questions about setting an array element value outside of the update
Date: 2011-12-05 03:43:43
Message-ID: CAK-MWwQJjimCLgSsAKpL=n7jGT2p5WzTfBPD6HSmc63NfjbqqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lets say i have subquery which produce array[], position and new_value

Is here less clumsy way to set array[position] to the new_value (not
update but just change an element inside an array) than:

SELECT
_array[1:pos-1]
||newval
||_array[_pos+1:array_length(_array, 1)]
FROM
(
SELECT _array,
pos,
newval
FROM
some_colmplicated_logic
);

The:
_array[1:pos-1]
||newval
||_array[_pos+1:array_length(_array, 1)]
part is very clumsy for my eyes.

PS: that is just small part of the complicated WITH RECURSIVE iterator in
real task.

--
Maxim Boguk
Senior Postgresql DBA.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-12-05 03:45:18 Re: WITH and WITH RECURSIVE in single query
Previous Message Tom Lane 2011-12-05 03:41:44 Re: WITH and WITH RECURSIVE in single query