EXTRACT

Function

Copies a portion of a string into a string variable.

Syntax

EXTRACT {dst_txt_var|date_var} FROM
{{src_txt_lit|_var|_col}|{src_date_var|_col}}
{start_num_lit|_var}{length_num_lit|_var}

Arguments

dst_txt_var|date_var

Text or date variable into which the extracted string is placed.

{src_txt_lit|_var|_col}|{src_date_var|_col}

Text or date variable, column, or literal from which to extract the string.

start_num_lit|_var

Starting location of the string.

length_num_lit|_var

Length of the string.

Description

You must specify the starting location of the string as an offset from the beginning of the string and its length. An offset of zero (0) begins at the left-most character; an offset of 1 begins one character beyond that, and so on.

If the source is a date variable or column, it is converted to a string before the extraction according to the following rules:

If the destination is a date variable, the string extracted from the source must be in one of the following formats:

Examples

extract  $state  from  $record  45  2
extract  $foo from “Oracle Rocks” 0 4 ! $foo=’Oracle’
extract  $zip_four  from  &zip  5  4
extract  $rec  from  $tape_block  #loc  #rec_len

See Also