Re: array problem with double quotes
От | Joe Conway |
---|---|
Тема | Re: array problem with double quotes |
Дата | |
Msg-id | 2b14bcf3-a159-48e9-b5fd-eb3170331fc8@joeconway.com обсуждение исходный текст |
Ответ на | array problem with double quotes (Olivier Leprêtre <o.lepretre@gmail.com>) |
Список | pgsql-sql |
On 10/14/2018 09:40 AM, Olivier Leprêtre wrote: > Is there a way to create arrays without postgres adding double quotes > when there are commas ? > > select v1,v2 from (values ('co',array[['ab'],['ab,da']])) sub (v1,v2) 'ab,da' is a single string literal element in the above SQL > where I wanted > > "co";"{{ab},{ab,da}}" If you do this: ---- select v1,v2 from (values ('co',array[['ab'],['ab','da']])) sub (v1,v2); ERROR: multidimensional arrays must have array expressions with matching dimensions ---- Doesn't work because you have differing dimensions. But these will work: ---- select v1,v2 from (values ('co',array[['ab',null],['ab','da']])) sub (v1,v2); v1 | v2 ----+--------------------- co | {{ab,NULL},{ab,da}} (1 row) ---- or ---- select v1,v2 from (values ('co','{{ab,null},{ab,da}}'::text[])) sub (v1,v2); v1 | v2 ----+--------------------- co | {{ab,NULL},{ab,da}} (1 row) ---- HTH, Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development
В списке pgsql-sql по дате отправления: