Re: using raise info to display array element

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Kiryl Mauryshchau <kirylm(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: using raise info to display array element
Date: 2011-08-05 18:27:32
Message-ID: CAFj8pRCAi6C1uR96QWYAApS49j7mWtjvBcd-PyGKGKL9mLFt6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

It working on my 9.1.

postgres=# select "public"."test_func_new" ();
INFO: 1st element: 5
test_func_new
───────────────
0
(1 row)

can you send more info about your environment?

Regards

Pavel Stehule

2011/8/5 Kiryl Mauryshchau <kirylm(at)gmail(dot)com>:
> 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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jaime Casanova 2011-08-05 18:42:57 Re: postgres table have a large number of relpages and occupied a big memory size
Previous Message Kiryl Mauryshchau 2011-08-05 18:17:36 using raise info to display array element