Re: argument of CASE/WHEN must not return a set

From: Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com>
To: George Weaver <gweaver(at)shaw(dot)ca>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: argument of CASE/WHEN must not return a set
Date: 2014-01-09 14:06:34
Message-ID: CADp-Sm4r_mVHORQfA4+E4Aot9uYyFWMqnJnFP1=DDpBA0A_W+w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jan 9, 2014 at 6:05 PM, Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com>wrote:

>
> On Thu, Jan 9, 2014 at 1:26 AM, George Weaver <gweaver(at)shaw(dot)ca> wrote:
>
>> ARRAY_TO_STRING( REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
>> development(# , ',')
>
>
> I guess this part of your statement will return 1,2, which is a set
>
> Can you try below:
> SELECT CASE
> WHEN LENGTH(ARRAY_TO_STRING(
> REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
> , ',')
> )
> = LENGTH('12-70510')
>
> THEN cast(ARRAY_TO_STRING(
> REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
> , ',') as varchar(100))
>
> ELSE ''
> END AS "12-70510";
>
> But anyways, I think the best way to do it is the way you have already
> figured (check the plan for both statements once you have sorted out the
> error)
>
>
>
Sorry about this response. The issue seems to be different.

> Best Regards,
> *Sameer Kumar | Database Consultant*
>
> *ASHNIK PTE. LTD.*101 Cecil Street, #11-11 Tong Eng Building, Singapore
> 069533
> M : *+65 8110 0350 <%2B65%208110%200350>* T: +65 6438 3504 |
> www.ashnik.com
> www.facebook.com/ashnikbiz | www.twitter.com/ashnikbiz
>
> [image: email patch]
>
> This email may contain confidential, privileged or copyright material and
> is solely for the use of the intended recipient(s).
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2014-01-09 15:30:58 Re: argument of CASE/WHEN must not return a set
Previous Message Karsten Hilbert 2014-01-09 11:51:08 Re: getting domain information from query results