Richard Welty <rwelty@averillpark.net> writes:
> given the lack of response, i'm going to presume that there is no published
> material on arrays and pl/pgsql
>
> can someone please 1) clearly state on whether arrays work in pl/pgsql and
> 2) if they do, please explain the syntax?
In PL/pgSQL you can declare arrays, set the value of arrays, and
reference array members; I have not discovered any way of setting
individual array members without having to re-set the entire array.
An example procedure follows:
CREATE FUNCTION try_array() RETURNS INTEGER AS '
DECLARE
array INTEGER[];
number INTEGER;
BEGIN
array := ''{3,4,6}'';
number := array[1];
RAISE NOTICE ''First element is %'', number;
number := array[2];
RAISE NOTICE ''Second element is %'', number;
number := array[3];
RAISE NOTICE ''Third element is %'', number;
array := ''{3,4,12}'';
number := array[3];
RAISE NOTICE ''Third element is now %'', number;
RETURN NULL;
END;
' LANGUAGE 'plpgsql';
--
Brandon Craig Rhodes http://www.rhodesmill.org/brandon
Georgia Tech brandon@oit.gatech.edu