pl_pgSQL array parameter and order of results returned - Mailing list pgsql-general

From Assad Jarrahian
Subject pl_pgSQL array parameter and order of results returned
Date
Msg-id 4bd3e1480512031548n268ca86kc1702e965ada2845@mail.gmail.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: "Uwe C. Schroeder"
Date:
Subject: Re: 8.1, OID's and plpgsql
Next
From: Peter Wiersig
Date:
Subject: Re: beginne' - inserting a record