Re: pl/pgsql list as parameter.

From: Assad Jarrahian <jarraa(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pl/pgsql list as parameter.
Date: 2005-11-06 02:17:19
Message-ID: 4bd3e1480511051817m1b8b4aa5y26e1286cc9031989@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am still unclear of how this works. Please help! I really would appreciate
this. This is what I have so far:

CREATE TYPE tp_lm_object AS(
.....
);

CREATE OR REPLACE FUNCTION
getLMs(int[],float(8), float(8)) RETURNS SETOF tp_lm_object AS $$
DECLARE
myrec record;
requestIds ALIAS for $1;
latitude ALIAS for $2;
longitude ALIAS for $3;
BEGIN
FOR myrec IN SELECT
LMID, LMOrigin ,LMType
FROM locationMessages
WHERE LMID IN (requestIDs) LOOP RETURN NEXT myrec; END LOOP; RETURN; END;
$$ LANGUAGE 'plpgsql';

I have two question

1) how do you call an pgsql function from command line when your function
takes an int array?
2) Will the above work. I am not sure, since I think I have to loop twice,
one for the myrec and one for the int[]. Can anybody please shed light on
this.
3) How do you call a method like this using the CallableStatement in JDBC. I
cannot seem to understand how to use setArray() succesfully?

Any help would be appreciated. Much thanks.

-assad

On 11/4/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Assad Jarrahian <jarraa(at)gmail(dot)com> writes:
> > How do you take in a list of int?
>
> Use an array.
>
> regards, tom lane
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message CSN 2005-11-06 02:21:28 sequence aliases?
Previous Message Florian G. Pflug 2005-11-05 20:45:41 Re: [GENERAL] Duplicate Row Removal