extract()

Scalar. Extracts and returns a portion of a given binary value.

Syntax

extract ( binary, startByte, numberOfBytes )

Parameters

binary

A binary value.

startByte

Integer representing the starting position for the extraction.

numberOfBytes

Integer representing the length of the extraction.

Usage

Extracts a binary value starting at the startByte argument for a specified length. The function takes a binary value and two integers as its arguments (for startByte and numberOfBytes), and the function returns a binary value.

For example, if a binary value was composed of bytes abcde, extract( bytes, 2,3 ) would produce cde. If length goes past end of binary value the rest of the binary value is returned. In the previous example, extract( bytes,2,4 ) would still return cde.

Example

extract ( hex_binary ('a1b2c3e4'),1,2)returns B2C3.

extract ( hex_binary ('a1b2c3e4'),3,1) returns E4.

extract ( hex_binary ('a1b2c3e4'),0,4)returns A1B2C3E4.