Search Postgresql Archives

Re: Implicit casts to array types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 14, 2012 at 9:32 AM, joshua <jzuellig@xxxxxxxxxxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux