DB2 Scalar functions - CONCAT


Volta a página anterior

Volta ao Menu das scalar functions

Volta ao Menu Principal


Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

CONCAT

The CONCAT function combines two arguments to form a string expression.

CONCAT(expression1, expression2)

The schema is SYSIBM.

expression1 or expression2
An expression that returns a value of one of the following data types:
  • Character, binary, or graphic string
  • Numeric value (this is implicitly cast to VARCHAR)
  • Datetime value (this is implicitly cast to VARCHAR)
  • Boolean value (this is implicitly cast to VARCHAR)

The following restrictions apply:

  • A binary string can be concatenated only with another binary string or with a character string that is defined as FOR BIT DATA.
  • A character string and a graphic string can be concatenated only in a Unicode database.
    The character string is converted to a graphic string before concatenation.
    The character string cannot be defined as FOR BIT DATA, because such a character string cannot be cast to a graphic data string.
  • If an argument is defined with CODEUNITS32, the other argument cannot be defined as FOR BIT DATA.

Result

The result of the function is a string that consists of the first argument followed by the second argument.
The data type and the length of the result is determined by the data types and lengths of the arguments, after any applicable casting is done.
For more information, refer to the Data Type and Length of Concatenated Operands table in Expressions.

If either argument can be null, the result can be null; if either argument is null, the result is the null value.

Notes

  • No check is made for improperly formed mixed data when doing concatenation.
  • The CONCAT function is identical to the CONCAT operator.
    For more information, see Expressions.

Example

Concatenate the column FIRSTNME with the column LASTNAME.
   SELECT CONCAT(FIRSTNME , LASTNAME) 
   FROM   EMPLOYEE 
   WHERE  EMPNO = '000010'
Returns the value CHRISTINEHAAS.


© Copyright IBM Corp.