Re: Implicit casts to array types

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Implicit casts to array types
Дата
Msg-id CAHyXU0xyj4QC=ZpHKoJ1t1q94jLM9jp=tnEoUwLMCH7M7PPcvA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Implicit casts to array types  (joshua <jzuellig@arbormetrix.com>)
Список pgsql-general
On Fri, Dec 14, 2012 at 9:32 AM, joshua <jzuellig@arbormetrix.com> wrote:
> Thanks, that function does help, but it still cannot cast directly to text[];
> The point of the functions was only ever to allow for an implicit cast to
> text[];

I'm not parsing that.  Why do you need an explicit cast?

> My goal is to be able to copy from a simple csv with nonarray entries
> ("1,2,3,...") and extract text arrays when the target table calls for it by
> creating an array of size 1. I believe this will require a custom implicit
> cast from unknown to text[], but if there's a better way to do it, I'd love
> to know.

If I want to handle csv data in an array, I usually do it like this:

*) create a one column table for staging the load
*) COPY the data to that table, intentionally faking the delimiter
*) process via conversion to array with 'string_to_array'.

the above only works if there's no commas inside your strings, so a
little extra massaging might be required in that case.

merlin


В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Read recover rows
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: JDBC to load UTF8@psql to latin1@mysql