FINDBYTES

The FINDBYTES function returns the byte position of the beginning of a specified group of bytes within a text expression.

Tip:

When you are using a single-byte character set, you can use the FINDCHARS function instead of the FINDBYTES function.

Return Value

INTEGER

Syntax

FINDBYTES(text-expressionbytes [starting-pos [LINENUM]])

Arguments

text-expression

The TEXT expression in which you are searching for the specified bytes. The value of text-expression can be a multiline value. In this case, FINDBYTES searches all lines for the specified bytes. The match must be exact, including a match of upper- and lowercase characters.

Tip:

When you must use this function on NTEXT values, use the CONVERT or TO_CHAR function to convert the NTEXT value to TEXT.
bytes

The group of bytes for which you are searching. When bytes is a multiline value, FINDBYTES ignores all lines except the first one.

When bytes is not found in text-expression, FINDBYTES returns zero. When the group of bytes occurs more than once, FINDBYTES returns the position of its first occurrence.

starting-pos

An INTEGER expression that specifies the byte position where the search in text-expression should start. The default is at position 1 (the first byte) in text-expression.

LINENUM

Specifies that FINDBYTES should return the line number instead of the byte position of the beginning of the specified text.

Examples

Example 7-95 Finding the Starting Position of a Byte Group

This example shows how to find the starting position of various groups of bytes in the literal TEXT value hellotherejoe.

The statement

SHOW FINDBYTES('hellotherejoe', 'joe')

produces the following output.

11

The statement

SHOW FINDBYTES('hellotherejoe', 'al')

produces the following output.

0