DB2 Scalar functions - SUBSTRB
The SUBSTRB function returns a substring of a string, beginning at a specified position in the string. Lengths are calculated in bytes.
The schema is SYSIBM.
The SUBSTRB function is available starting with version 9.7 Fix Pack 1.
The expression must return a value that is a built-in character string, numeric value, Boolean value, or datetime value. If the value is not a character string, it is implicitly cast to VARCHAR before the function is evaluated. In a Unicode database, if the value is a graphic data type, it is implicitly cast to a character string data type before the function is evaluated. Any number (zero or more) contiguous bytes of this expression constitute a substring of this expression.
If start is positive, then the start position is calculated from the beginning of the string. If start is greater than the length of string, then a zero length string is returned.
If start is negative, then the start position is calculated from the end of the string and by counting backwards. If the absolute value of start is greater than the length of string, then a zero length string is returned.
If start is 0, then a start position of 1 is used.
If the length is:
The default length is the number of bytes from the position specified by start to the last byte of string.
If string is a CHAR or VARCHAR data type, the result of the function is a VARCHAR data type. If string is a CLOB, the result of the function is a CLOB. If string is a BINARY or VARBINARY data type, the result of the function is a VARBINARY data type. If string is a BLOB, the result of the function is a BLOB. If the first argument is a host variable that is not a binary string and not a FOR BIT DATA character string, the code page of the result is the section code page; otherwise, it is the code page of the first argument.
The length attribute of the result is the same as the length attribute of the first argument unless both start and length arguments are specified and defined as constants. In this case, the length attribute of the result is determined as follows:
If any argument of the SUBSTRB function can be null, the result can be null; if any argument is null, the result is the null value.
SUBSTRB(:NAME, :SURNAME_POS)
SUBSTRB(:NAME, :SURNAME_POS,1)
SELECT * FROM PROJECT WHERE SUBSTRB(PROJNAME,-3) = 'ING'