Search Postgresql Archives

pl_pgSQL array parameter and order of results returned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux