Search Postgresql Archives

array_to_records function

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

 



Here I'm posting a function to convert array to records.
any other suggestions are welcome
 
create or replace function array_to_records(int[]) RETURNS SETOF record AS $$
DECLARE
  ret_rec record;
  a int;
  b int;
BEGIN
   b = length(array_dims($1));
   a = substr(array_dims($1),4, (b-4)  );
   FOR i IN 1.. a LOOP
     FOR ret_rec IN select i, $1[i] LOOP
     RETURN NEXT ret_rec;
     END LOOP;
   END LOOP;
   RETURN;
END;
$$
LANGUAGE 'plpgsql';

[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