argument of CASE/WHEN must not return a set - Mailing list pgsql-general

From George Weaver
Subject argument of CASE/WHEN must not return a set
Date
Msg-id F6E2A4DE57B240D69479FA734FFF3541@D420
Whole thread Raw
Responses Re: argument of CASE/WHEN must not return a set  (Sameer Kumar <sameer.kumar@ashnik.com>)
List pgsql-general
Good morning,
 
I've have solved my problem in another way, but I am curious as to why I am getting the following error.
 
The following returns a boolean value a expected:
 
development=# SELECT LENGTH(ARRAY_TO_STRING(  REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
development(#                        , ',')
development(#                        )  =
development-#        LENGTH('12-70510')
development-#
development-#     AS "12-70510";
 12-70510
----------------
 f
(1 row)
 
But if I put the comparison into a CASE or WHERE clause I get this error:
 
development=# SELECT CASE
development-#             WHEN LENGTH(ARRAY_TO_STRING(  REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
development(#                                         , ',')
development(#                         )
development-#                  = LENGTH('12-70510')
development-#
development-#             THEN ARRAY_TO_STRING(  REGEXP_MATCHES('12-70510','^[0-9,0-9.0-9]+')
development(#                                  , ',')
development-#
development-#             ELSE ''
development-#         END AS "12-70510";
ERROR:  argument of CASE/WHEN must not return a set
LINE 2:             WHEN LENGTH(ARRAY_TO_STRING(  REGEXP_MATCHES('12...
 
 
What am I missing?
 
Thanks,
George

pgsql-general by date:

Previous
From: Keith Fiske
Date:
Subject: Re: Planning error in dynamic string creation in plpgsql
Next
From: Nelson Green
Date:
Subject: Re: Last inserted row id with complex PK