LAND

The LAND function returns a string that is the logical 'AND' of the argument strings. This function takes the first argument string, does an AND operation with the next string, and then continues to do AND operations with each successive argument using the previous result. If a character-string argument is shorter than the previous result, it is padded with blanks. If a binary-string argument is shorter than the previous result, it is padded with hexadecimal zeros.

Read syntax diagramSkip visual syntax diagramLAND(expression ,expression )

The arguments must be compatible.

expression
An expression that returns a value of any built-in numeric or string data type, but cannot be LOBs. The arguments cannot be mixed data character strings, UTF-8 character strings, or graphic strings. A numeric argument is cast to a character string before evaluating the function. For more information about converting numeric to a character string, see VARCHAR.

The arguments are converted, if necessary, to the attributes of the result. The attributes of the result are determined as follows:

  • If all the arguments are fixed-length strings, the result is a fixed-length string of length n, where n is the length of the longest argument.
  • If any argument is a varying-length string, the result is a varying-length string with length attribute n, where n is the length attribute of the argument with greatest length attribute. The actual length of the result is m, where m is the actual length of the longest argument.

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

The CCSID of the result is 65535.

Example

  • Assume the host variable L1 is a CHARACTER(2) host variable with a value of X'A1B1', host variable L2 is a CHARACTER(3) host variable with a value of X'F0F040', and host variable L3 is a CHARACTER(4) host variable with a value of X'A1B10040'.
      SELECT LAND(:L1,:L2,:L3)
        FROM SYSIBM.SYSDUMMY1
    Returns the value X'A0B00040'.