using raise info to display array element
От | Kiryl Mauryshchau |
---|---|
Тема | using raise info to display array element |
Дата | |
Msg-id | CAKFAgEhPOhSwbc1JQNGqM805dB+nWzHiY3Y4xQ7ZSgJz=PWKAQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: using raise info to display array element
|
Список | pgsql-general |
I am trying to print values of an array one by one, but it doesn't work.
For example, if i want to print entire array at once, it does work:
CREATE OR REPLACE FUNCTION "public"."test_func" () RETURNS integer AS
$body$
declare
i int;
v_arr integer[] = '{0, 1}';
begin
v_arr[1] := 5;
v_arr[2] := 7;
raise info 'entire array: %', v_arr;
return 0;
end
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
But then if I try this:
CREATE OR REPLACE FUNCTION "public"."test_func_new" () RETURNS integer AS
$body$
declare
i int;
v_arr integer[] = '{0, 1}';
begin
v_arr[1] := 5;
v_arr[2] := 7;
raise info '1st element: %', v_arr[1];
return 0;
end
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
.. and it doesn't compile.
Can someone help me? Thanks!
--
Regards,
Kiryl Mauryshchau
For example, if i want to print entire array at once, it does work:
CREATE OR REPLACE FUNCTION "public"."test_func" () RETURNS integer AS
$body$
declare
i int;
v_arr integer[] = '{0, 1}';
begin
v_arr[1] := 5;
v_arr[2] := 7;
raise info 'entire array: %', v_arr;
return 0;
end
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
But then if I try this:
CREATE OR REPLACE FUNCTION "public"."test_func_new" () RETURNS integer AS
$body$
declare
i int;
v_arr integer[] = '{0, 1}';
begin
v_arr[1] := 5;
v_arr[2] := 7;
raise info '1st element: %', v_arr[1];
return 0;
end
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
.. and it doesn't compile.
Can someone help me? Thanks!
--
Regards,
Kiryl Mauryshchau
В списке pgsql-general по дате отправления: