Re: Array as parameter in plpgSQL functions

From: Jie Liang <jliang(at)ipinc(dot)com>
To: Sveinung Haslestad <sveinung(dot)haslestad(at)swipnet(dot)se>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Array as parameter in plpgSQL functions
Date: 2001-01-31 20:47:48
Message-ID: Pine.BSF.4.10.10101311240550.50465-100000@tidal.ipinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


e.g.

create function foo(_int4) returns int2 as'
declare
a _int4 alias for $1;
i int:=1;
begin
while a[i] loop
i:=i+1;
end loop;
return i-1;
end;
' language 'plpgsql';

you can call it by:

select foo('{1232131,12312321,3424234}');

you should get 3.

Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang(at)ipinc(dot)com
www.ipinc.com

On Wed, 31 Jan 2001, Sveinung Haslestad wrote:

> I need to pass an array to a function ( int4, variable number of elements) .
> How do i declare the parameter, and how can i tell the numer of recieved elements?
>
> Thanks
> /Sveinung
>
>
>
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message miss 2001-01-31 21:25:18 Archival of Live database to Historical database
Previous Message Sveinung Haslestad 2001-01-31 20:30:09 Array as parameter in plpgSQL functions