From: | Assad Jarrahian <jarraa(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | pl_pgSQL array parameter and order of results returned |
Date: | 2005-12-03 23:48:28 |
Message-ID: | 4bd3e1480512031548n268ca86kc1702e965ada2845@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi All,
I have a quick question. So I pass an array (int containing primary
keys) to a pgSQL function and I want the results to be in the exact
same order as the ints in the array. Is there a way to do this ?
currently my code looks like this
CREATE OR REPLACE FUNCTION getlms(_int4)
RETURNS SETOF lms AS
$BODY$
DECLARE
myrec record;
requestIds ALIAS for $1;
BEGIN
FOR myrec IN SELECT * FROM lms
WHERE LMID = ANY (requestIDs) LOOP RETURN NEXT myrec; END LOOP;
RETURN; END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
It returns the rows in the order in which it finds them (smallest to
biggest primary key)? Any help, suggestions would be appreciated. Much
thanks in advance.
-assad
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-12-04 01:14:09 | Re: Numeric 508 datatype |
Previous Message | Anton Nikiforov | 2005-12-03 23:39:57 | int to inet conversion |