Grant,
The only way I know to enumarate arrays is procedural. This is a good
reason to stay away from arrays except in buffer and temporary tables
(aside from the fact that array columns violate the relational principle
of atomicity).
The following sample procedure, paraphrased from Bruce Momjian's book
(which you should buy, hint, hint) illustrates enumerating an array of
INT4 values:
CREATE FUNCTION count_array ( INT4[] ) RETURNS INT2
AS '
DECLARE array_loop INT2;array_col ALIAS FOR $1;
BEGINarray_loop := 1;WHILE array_col[array_loop] LOOP array_loop = array_loop + 1;END LOOP;array_loop := array_loop
-1RETURN array_loop;
END;'
LANGUAGE 'plpgsql';
-Josh
--
______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete
informationtechnology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small
businesses fax 621-2533 and non-profit organizations. San Francisco