Search Postgresql Archives

Re: Questions about setting an array element value outside of the update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Johnston <polobo@xxxxxxxxx> writes:
>> 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)]

> I do not know if there is a cleaner way but regardless you should code
> your logic as a function.

Inside a plpgsql function, you could just do

	array[pos] := newval;

so perhaps it'd be worth creating a helper function that's a wrapper
around that.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux