Reputation: 205
I am new at PostgreSQL
, I use array
type in PostgreSQL
WITH intarr AS (
SELECT
ARRAY [ s.days,s.hours ] ::int[] AS arr
FROM summary s
WHERE s.hours != 2
)
SELECT ARRAY(SELECT * from intarr );
I get this error:
[Err] ERROR: could not find array type for data type integer[]
I find a way change
ARRAY [ s.days,s.hours ] ::int[] AS arr
row to this
ARRAY [ s.days,s.hours ] ::varchar AS arr
I get result like : {"{1,3}","{2,3}"}
. But I need result int[][]
type .How I convert one-dimensional array
to two-dimensional array
Upvotes: 1
Views: 1112
Reputation: 205
I use it for now,I don't think it is perfect way.
WITH intarr AS (
SELECT
ARRAY [ s.days,s.hours ] ::VARCHAR AS arr
FROM
summary s
WHERE
s.hours != 2
)
SELECT replace((SELECT ARRAY(SELECT arr from intarr)::VARCHAR), '"', '')::int[][]
Upvotes: 1