1

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

1
  • I did it, but I don't know is it good solution ? SELECT replace( (SELECT ARRAY(SELECT arr from intarr)::VARCHAR), '"', '')::int[][] Commented Oct 1, 2015 at 6:32

1 Answer 1

1

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[][]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.