Re: Passing array to PL/SQL and looping

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Passing array to PL/SQL and looping
Дата
Msg-id 200209261820.08106.josh@agliodbs.com
обсуждение исходный текст
Ответ на Passing array to PL/SQL and looping  (Peter Atkins <peter.atkins@NXCD.com>)
Ответы Re: Passing array to PL/SQL and looping
Список pgsql-sql
Peter,

> I'm a newbie to PL/SQL and need help badly. I'm trying to pass my array of
> id's to the function and then loop through until the array is empty. I know
> there must be atleast five things I'm doing wrong.

Simplified example:

CREATE FUNCTION test_array (INT[] )
RETURNS INT AS '
DECLARE id_array ALIAS for $1;count_it INT;
BEGIN
count_it := 1;
WHILE id_array[count_it] LOOPcount_it := count_it + 1;
END LOOP;
RETURN (count_it - 1);
END;'
LANGUAGE 'plpgsql';

returns the number of elements in the supplied array.

--
Josh Berkus
josh@agliodbs.com
Aglio Database Solutions
San Francisco


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

Предыдущее
От: Jordan Reiter
Дата:
Сообщение: Re: Case Sensitive "WHERE" Clauses?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: FW: query problem "server sent binary data ... without