From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Mike Martin <redtux1(at)gmail(dot)com> |
Cc: | pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Use multidimensional array as VALUES clause in insert |
Date: | 2020-08-11 13:22:00 |
Message-ID: | CAKFQuwYayZ2dVHtZb0SRNq7=9nJ0kfjecRk6_=D_dKTv2LuevQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tuesday, August 11, 2020, Mike Martin <redtux1(at)gmail(dot)com> wrote:
> 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
>
There is no simple way to have each element of an array be inserted into a
different column nor have each element populate a different row. You
should avoid the multi-dimensional array if at all possible.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2020-08-11 14:08:32 | Re: Use multidimensional array as VALUES clause in insert |
Previous Message | Samed YILDIRIM | 2020-08-11 10:58:20 | Re: Use multidimensional array as VALUES clause in insert |