Mark Gibson wrote:
> b) resetting the lower bound of the array (without affecting elements)?
> eg: set_array_lower(1 || ARRAY[2,3,4], 1) -- 2nd arg is the new
> lower bound
After a bit more playing about, i've discovered a kludgy work-around for
resetting an array's lower bound to 1.
To demonstrate:
> SELECT array_lower(1 || ARRAY[2,3,4], 1);
array_lower
-------------
0
> SELECT array_lower((1 || ARRAY[2,3,4])[-100:100], 1);
array_lower
-------------
1
A slice always has a lower bound of 1, so using a slice that extends well
beyond the bounds of the array will return the array with its lower bound
set at 1.
--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.