- Categories:
Semi-structured Data Functions (Extraction)
GET¶
Extracts a value from an object or array; returns NULL if either of the arguments is NULL.
Note that this function should not be confused with the GET DML command.
- See also:
Syntax¶
GET( <object> , <field_name> )
GET( <v> , <field_name> )
GET( <array> , <index> )
GET( <v> , <index> )
Usage Notes¶
GET applies case-senstive matching to field names. For case-insenstive matching, try GET_IGNORE_CASE instead.
GET is a binary function that can be called in the following ways:
object
is an OBJECT value andfield_name
is a string value, which can be a constant or an expression.This variation of GET extracts VARIANT value of the field with the provided name from the object value. If the field is not found, NULL is returned. The field name should not be an empty string.
v
is a VARIANT value andfield_name
is a string value, which can be a constant or an expression.Works similarly to GET with
object
, but additionally checks thatv
contains an object value (and returns NULL ifv
does not contain an object).array
is an ARRAY value andindex
is an integer, which can be a constant or an expression.This variation of GET extracts VARIANT value of the array element with the given index. If the index points outside of the array boundaries, or if the indexed element does not exist (in sparse arrays) this function returns NULL.
v
is a VARIANT value andindex
is an integer, which can be a constant or an expression.Works similarly to GET with
array
, but additionally checks thatv
contains an array value (and returns NULL ifv
does not contain an array).
Examples¶
Extract the maximum value of the field temperature
from all objects in the vartab
table which contain the field and the field sensorType
equal to indoor
:
SELECT MAX(AS_REAL(GET(v, 'temperature'))) FROM vartab WHERE AS_CHAR(GET(v, 'sensorType')) = 'indoor';
For more detailed examples, see Querying Semi-structured Data.