Re: Instaltiating an ARRAY within a function

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Instaltiating an ARRAY within a function
Дата
Msg-id 162867790712120548h284fc461tcbf6c76a84a0fc1c@mail.gmail.com
обсуждение исходный текст
Ответ на Instaltiating an ARRAY within a function  ("Abraham, Danny" <danny_abraham@bmc.com>)
Список pgsql-general
Hello

problem is elsewhere. PostgreSQL doesn't support by ref variables. In
your sample you have to do:

CREATE OR REPLACE FUNCTION callarr()
returns integer
AS
$Z$
DECLARE
 x varchar[6];
BEGIN
x := arr(x); <-------!!!!!!!!!
RAISE NOTICE 'x[1]=%',x[1];
return 0;
end;
$Z$ LANGUAGE 'plpgsql' VOLATILE;

Pavel

On 12/12/2007, Abraham, Danny <danny_abraham@bmc.com> wrote:
> ===========================================
>
> CREATE OR REPLACE FUNCTION arr( inout x varchar[] )
> AS
> $Z$
> DECLARE
>   i integer;
> BEGIN
> select ARRAY['Danny','Eissam','Moshe'] into x;
> end;
> $Z$ LANGUAGE 'plpgsql' VOLATILE;
>
> ===========================================
>
> CREATE OR REPLACE FUNCTION callarr()
> returns integer
> AS
> $Z$
> DECLARE
>   x varchar[6];
> BEGIN
> perform arr(x);
> RAISE NOTICE 'x[1]=%',x[1];
> return 0;
> end;
> $Z$ LANGUAGE 'plpgsql' VOLATILE;
>
> ===========================================
>
> select callarr();
> NOTICE:  x[1]=<NULL>  ??? Should have been DANNY
>
>
> Should it work?
>
> Thanks
>
> Danny
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

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

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: executing a procedure with delay
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Multiple clusters on one box for PITR