Concatenating More than Two Strings

Moderator: NorbertKrupa

Post Reply
User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Concatenating More than Two Strings

Post by JimKnicely » Thu Mar 14, 2013 12:21 pm

The CONCAT function, according to the Vertica documentation, is used to concatenate two or more VARBINARY strings.

Unfortunately, if you try to concatenate more than two strings you’ll get an error:

Code: Select all

dbadmin=> SELECT concat('this', ' works');
   concat
------------
this works
(1 row)

dbadmin=> SELECT concat('this', ' does not ', 'work');
ERROR 3457:  Function concat(unknown, unknown, unknown) does not exist, or permission is denied for concat(unknown, unknown, unknown)
HINT:  No function matches the given name and argument types. You may need to add explicit type casts
If you need to concatenate more than two strings, use the concatenation operator (two consecutive vertical bars) instead:

Code: Select all

dbadmin=> SELECT 'Vertica' || ' has' || ' a' || ' few' || ' quirks' Blasphemy;
        Blasphemy
--------------------------
Vertica has a few quirks
(1 row)
Have fun!
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica Tips, Lessons and Examples”