Re: setof or array as input parameter to postgresql 8.2 functions

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "Jyoti Seth *EXTERN*" <jyotiseth2001(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: setof or array as input parameter to postgresql 8.2 functions
Date: 2007-06-13 13:09:56
Message-ID: AFCCBB403D7E7A4581E48F20AF3E5DB2035BD920@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

> I have to pass a set of values and arrays in postgresql 8.2
> functions. But I am not getting any help on that. Please let
> me know if any one has idea.

Something like this?

CREATE OR REPLACE FUNCTION sample(avalue integer, anarray text[])
RETURNS void LANGUAGE plpgsql STRICT AS
$$DECLARE
i integer;
BEGIN
-- I can access the value
i := avalue;
-- I can access the array
i := anarray[2];
END;$$;

Called like

SELECT sample(3, ARRAY[1, 2, 3]);

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2007-06-13 13:13:15 Re: how to speed up query
Previous Message Johannes Konert 2007-06-13 13:00:14 pg_xlog - files are guaranteed to be sequentialy named?

Browse pgsql-sql by date

  From Date Subject
Next Message A. R. Van Hook 2007-06-13 13:19:05 join problem
Previous Message Pavel Stehule 2007-06-13 12:55:13 Re: [SQL] setof or array as input parameter to postgresql 8.2 functions