Re: Implicit casts to array types - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Implicit casts to array types
Date
Msg-id CAHyXU0xyj4QC=ZpHKoJ1t1q94jLM9jp=tnEoUwLMCH7M7PPcvA@mail.gmail.com
Whole thread Raw
In response to Re: Implicit casts to array types  (joshua <jzuellig@arbormetrix.com>)
List 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 by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Read recover rows
Next
From: Adrian Klaver
Date:
Subject: Re: JDBC to load UTF8@psql to latin1@mysql