Subsections


Type Information Expressions

OQL provides two type information unary operators: typeof and classof. The first one takes any operand type, while the second one takes an oid or an object operand. Note that because of the precedence of these operators, parenthesis are necessary to get type information about a non-primary operand. For instance, typeof 1+2 is not valid: you should use typeof (1+2).

typeof operator

The typeof operator is used to get the type of any OQL atom. It evaluates its operand and returns the string type of its operand. For instance: typeof 1 returns "int" while typeof "hello" returns "string".

General Information
Operator typeof
Syntax typeof expr
Type unary
Operand Type any type
Result Type string
Function returns the type of the atom

Expression Examples
typeof "alpha" "string"
typeof (1+20.) "float"
typeof list(1, 2, 3) "list"
typeof first(select Person) "oid"
typeof 1+3049 raises an error
typeof alpha type of the value of alpha
typeof &alpha ident

classof operator

typeof operator

The classof operator is used to get the class of any oid or object. It evaluates its operand and returns the string class of its operand. For instance: classof first(select Person) returns "Person" while typeof new Car() returns "Car".

General Information
Operator classof
Syntax classof expr
Type unary
Operand Type oid or object
Result Type string
Function returns the class of the operand

Expression Examples
classof first(select class) "basic_class"
classof (c := new Car(num : 10)) "Car"
classof NULL ""
classof first(select Person).spouse "Person" or NULL
classof 1 raises an error

EyeDB manual