Re: Can I reset the lower bound of an array.
От | Mark Gibson |
---|---|
Тема | Re: Can I reset the lower bound of an array. |
Дата | |
Msg-id | 40854D0B.6000005@cromwell.co.uk обсуждение исходный текст |
Ответ на | Can I reset the lower bound of an array. (Mark Gibson <gibsonm@cromwell.co.uk>) |
Ответы |
Re: Can I reset the lower bound of an array.
|
Список | pgsql-general |
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.
В списке pgsql-general по дате отправления: