Re: Stored function - send array as parameter to stored function

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored function - send array as parameter to stored function
Date: 2008-11-13 02:44:45
Message-ID: 491B949D.20400@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, this one got me, also. Strangely, you need to do:

select iterate('{1,2}');

Also, you have a typo in your function: arry_upper(a,1)

b

hendra kusuma wrote:
> Hi,
> I'm new here
> I've been doing a little self-learning about postgresql
> and find it very interesting
>
> I've been trying to create a stored procedure that receive array as
> parameter and find a good and working example on the web
>
> the code looks like this
>
> create or replace function iterate(a int[])
> returns void as $$
> begin
> for i in array_lower(a,1)..arry_upper(a,1) loop
> raise notice '%', a[i];
> end loop;
> end;
> $$ language plpgsql strict;
>
> my problem is, how should I call this function?
> I tried
> select iterate(1,2)
> select iterate([1,2])
> select iterate({1,2})
> none of them are working
>
> how is it really to call this function
>
> Thank you
> Hendra
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hendra kusuma 2008-11-13 05:41:46 exception
Previous Message Greg Smith 2008-11-13 02:33:26 Re: Upgrading side by side in Gentoo