SQL CONCAT scalar function in DB2 for i SQL |
CONCAT
The CONCAT function combines two arguments to form a string expression. Both the arguments must be compatible. The result is NULL if any argument is NULL value.
Syntax
CONCAT(expression1,expression2)
Example#1:
SELECT CONCAT('A', 'B') FROM SYSIBM.SYSDUMMY1
Here, both the strings gets combined and not null result will be returned.
CONCAT AB
Example#2:
SELECT CONCAT('NULL', 'A') FROM SYSIBM.SYSDUMMY1
Or
SELECT CONCAT('A', NULL) FROM SYSIBM.SYSDUMMY1
Or
SELECT CONCAT(NULL, NULL) FROM SYSIBM.SYSDUMMY1
Here, return result will be NULL if at least one argument is NULL value
CONCAT -
Example#3:
SELECT CONCAT(1,2) OM SYSIBM.SYSDUMMY1
Here, Either any of the argument can be numeric datatype and they will be combined and casted implicitly to a VARCHAR data type
CONCAT ( 1 , 2 ) 12
Or
SELECT CONCAT(1,'A') OM SYSIBM.SYSDUMMY1
CONCAT ( 1 , 'A' ) 1A