Use multidimensional array as VALUES clause in insert

From: Mike Martin <mike(at)redtux(dot)plus(dot)com>
To: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Use multidimensional array as VALUES clause in insert
Date: 2020-08-11 10:47:58
Message-ID: CAOwYNKbE7OSDscT5uJX6ruW8XpupmbG9-msrVhqpOhkBYPUVyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Is this possible? I have seen examples with array literals as VALUES
string, but I cant seen to get it to work with an actual array.

testing code

--This gets me a multidimensional array
with arr AS (
SELECT ARRAY(SELECT
ARRAY[fileid::text,tagname,array_to_string(tagvalue,E'\b')]
FROM tagdata_all) -- limit 100)
arr1
)
--Then

INSERT INTO tagdatatest2
SELECT arr1::text[] FROM arr --doesnt work only populates one column with
original array

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mike Martin 2020-08-11 10:50:06 Use multidimensional array as VALUES clause in insert
Previous Message ml 2020-08-09 15:04:27 Re: recursive sql