Use multidimensional array as VALUES clause in insert

From: Mike Martin <redtux1(at)gmail(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:50:06
Message-ID: CAOwYNKYLxdrqzxQu=HGn+Gf+7qzOr8LMUmbnWJXpOw5_W=TVsQ@mail.gmail.com
Views: Whole Thread | Raw Message | 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 Samed YILDIRIM 2020-08-11 10:58:20 Re: Use multidimensional array as VALUES clause in insert
Previous Message Mike Martin 2020-08-11 10:47:58 Use multidimensional array as VALUES clause in insert