Database Reference
In-Depth Information
row_out = array_in[i];
RETURN NEXT ;
END LOOP;
END;
$$ LANGUAGE plpgsql;
This work nicely on an array of integers.
hannu=# select array_to_rows('{1,2,3}'::int[]);
-[ RECORD 1 ]-+--
array_to_rows | 1
-[ RECORD 2 ]-+--
array_to_rows | 2
-[ RECORD 3 ]-+--
array_to_rows | 3
It also works nicely on an array of dates.
hannu=# select
array_to_rows('{"1970-1-1","2012-12-12"}'::date[]);
-[ RECORD 1 ]-+-----------
array_to_rows | 1970-01-01
-[ RECORD 2 ]-+-----------
array_to_rows | 2012-12-12
It even works on arrays of records from user-defined tables.
hannu=# create table mydata(id serial primary
key, data text);
NOTICE: CREATE TABLE will create implicit
sequence "mydata_id_seq" for serial column
"mydata.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create
implicit index "mydata_pkey" for table "mydata"
CREATE TABLE
Search WWH ::




Custom Search