SQL concat() gives error when more than 2 arguments

LabKey Support Forum (Inactive)
SQL concat() gives error when more than 2 arguments Will Holtz  2016-04-26 14:42
Status: Closed
 
The Labkey SQL documentation (https://www.labkey.org/wiki/home/Documentation/page.view?name=labkeysql) indicates that concat() can take n arguments. However the following statement

SELECT concat('a', 'b', 'c') AS combined;

gives the error:

Error on line 1: CONCAT function expects 2 arguments

This is on Labkey v16.1 with Postgres v9.5.2.

-Will
 
 
Jon (LabKey DevOps) responded:  2016-04-26 14:50
Hi Will,

This looks like a bug. It should take more than two arguments for sure.

I'll get this escalated and looked into.

Regards,

Jon
 
Jon (LabKey DevOps) responded:  2016-04-26 14:57
Hi Will,

I've created bug https://www.labkey.org/issues/home/Developer/issues/details.view?issueId=26316 on this.

Thanks for bringing it to our attention.

The only way I've found to work around this is a little ugly, but you can concat the concat like this:

SELECT concat(concat('a', 'b'), 'c') as combined

Not ideal, but it works.

Regards,

Jon
 
Jon (LabKey DevOps) responded:  2016-04-26 21:13
Hi Will,

So it looks like our docs actually need to be revised to indicate that only two arguments can be used. However, you can use operators to give you the same result.

iSELECT 'a' || 'b' || 'c' AS combined;

Regards,

Jon