CREATE OR REPLACE FUNCTION explode_array(in_array anyarray)
RETURNS SETOF anyelement AS
$BODY$
select ($1)[s] from generate_series(1,array_upper($1, 1)) as s;
$BODY$
LANGUAGE 'sql' IMMUTABLE
COST 100
ROWS 1000;
Example use:
=> select explode_array(array[1,2,3]);
explode_array
---------------
1
2
3
(3 rows)
No comments:
Post a Comment