hi, all: there is a function in postgresql contrib "int_arrgreagte": CREATE OR REPLACE FUNCTION int_array_enum(int4[]) RETURNS setof integer AS '$libdir/int_aggregate','int_enum' LANGUAGE C IMMUTABLE STRICT; I can use this function like this: chry=# SELECT int_array_enum('{1,2}'); or chry=# SELECT * from int_array_enum('{1,2}'); result: int_array_enum ---------------- 1 2 also, I can use it like this: SELECT int_array_enum('{1,2}'), int_array_enum('{1,3}'); result: int_array_enum | int_array_enum ----------------+---------------- 1 | 1 2 | 3 I try to write my own function with the same return type in plpgsql: create or replace function my_int_array_enum(state integer[]) returns setof integer as $$ declare i integer; begin for i in array_lower(state,1)..array_upper(state,1) loop return next state[i]; end loop; return; end; $$ language 'plpgsql' immutable; but, when I use my function like this: test=# SELECT my_int_array_enum('{1,2}'); I got the error said as below: ERROR: set-valued function called in context that cannot accept a set (I know, SELECT * from my_int_array_enum('{1,2}') is ok) can anybody tell me the reason, thanks for any help:D regards, -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general