Substring ([s,e])
The [] (square brackets)
extract a substring.
Syntax
Note: In the next(s) syntax diagram(s), the
[ ] { } |
symbols are part of the syntax.Single character position form:
variable [ pos ]Start/end position form:
variable [ start-pos , end-pos ]- variable must be a variable defined with the
CHARorVARCHARtype. - pos defines the position of the character to be extracted.
- start-pos defines the position of the first character of the substring to be extracted.
- end-pos defines the position of the last character of the substring to be extracted.
Usage
The [] (square brackets) notation following a CHAR or VARCHAR variable extracts a substring
from that character variable.
The pos, start-pos and end-pos arguments can be expressed in bytes or characters, depending on the length semantics used in your programs.
Important:
Substring expressions in SQL statements are evaluated by the database server. This may have a different behavior than the substring operator of the language.
Example
MAIN
DEFINE s CHAR(10)
LET s = "abcdef"
DISPLAY s[3,4]
END MAIN