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