Re: Array fundamentals

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: idc danny <idcdanny(at)yahoo(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Array fundamentals
Date: 2012-07-18 19:32:46
Message-ID: CA+TgmobVbh3XGONv_HKFhDgSyfuY6cBcR4k0+Jj7zm6380V6dA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

On Sat, Jun 2, 2012 at 1:05 PM, idc danny <idcdanny(at)yahoo(dot)com> wrote:
> Hi all,
> I got 2 complementary functions, which will do opposite things.
> 1 - CombineStrings(stringarray character varying[]) RETURNS character
> varying
> This one will take as parameter an array of strings and will return a string
> with some formatted information inside
> 2- SplitString2Array(stringtosplit character varying) RETURNS character
> varying[]
> This one will take as parameter a formatted string and will return an array
> of string
>
> The following is true, both works just fine :
> select SplitString2Array(CombineStrings(ARRAY['abba', 'queen']))
> will return {'abba', 'queen'}
>
> Now, if I want do do the following:
> select CombineStrings(ARRAY[SplitString2Array("SomeTextColumn"), 'New string
> to add']) from "SomeTable"
> i get the following error:
> array value must start with "{" or dimension information
>
> What am I doing wrong, I am feeling I still don't get the array
> fundamentals. My goal is to add to inside formatted information in the
> column "SomeTextColumn" my new string 'New string to add' in the same manner
> if I would been used the following:
> Insert into "SomeTable"("SomeTextColumn") values
> (CombineString(ARRAY['abba', 'queen', 'New string to add']))

It sounds like one or both of your functions have a bug in them, but
without knowing what they're supposed to do or seeing the source code,
it's pretty hard to guess what it might be.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-07-18 20:07:02 Re: Trouble with NEW
Previous Message Bob Pawley 2012-07-18 19:28:00 Re: Trouble with NEW

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2012-07-18 20:00:53 Re: Sequencial scan in a JOIN
Previous Message Peter Geoghegan 2012-07-18 18:40:28 Re: optimizing queries using IN and EXISTS