Accessing array elements in a FOR PL/pgsql loop

Поиск
Список
Период
Сортировка
От Igor Katson
Тема Accessing array elements in a FOR PL/pgsql loop
Дата
Msg-id 499D3633.2030702@gmail.com
обсуждение исходный текст
Ответы Re: Accessing array elements in a FOR PL/pgsql loop  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
For each element in the array, I need to make some operation with plpgsql.
I usually use the syntax:

DECLARE
  array_len int;
BEGIN
  array_len := array_upper(i_array, 1);
  FOR i IN 1 .. array_len
  LOOP
     SOME OPERATION (i_array[i])
  END LOOP;

But I don't like that. Is there any built-in way to do that without
using the length, i.e like in python, e.g.
  for element in array:
    ....
This example does not work in Postgres.

I think I need a built-in function to make a column from an array, like
in the backwards operation SELECT ARRAY(column)

В списке pgsql-general по дате отправления:

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: postgres wish list
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: When adding millions of rows at once, getting out of disk space errors