The Object Query Language (in short: OQL) is the language used by iTop for defining queries that retrieve persisted objects.
OQL queries are used in many places in iTop (audit rules, notifications, etc.) to define or configure sets of objects.
The goal of the OQL language is to hide the complexity of the actual SQL schema of the data model while leveraging its definition for providing a secure (access rights are enforced by the queries), powerful (complex conditions can be expressed in OQL), efficient (one OQL query is translated into exactly one SQL query), object-aware (class inheritance is respected) and simple syntax.
The OQL syntax is similar to the syntax of SQL, the OQL grammar is basically a subset of the SQL grammar.
As of now, only SELECT statements have been implemented.
Such statements do return two kinds of data set:
Either a list of objects of the selected class.
Or a list of objects and related objects (several classes of objects per row)
The OQL language is case sensitive and all keywords are to be written in UPPERCASE
The OQL grammar can be described as following using the BNF syntax:
query ::= select-query [UNION query] select-query ::= SELECT class-reference [class-joined] [WHERE expression] class-reference ::= name [AS name] class-joined ::= JOIN class-reference ON name.name = name.id name ::= string | `string` expression ::= scalar | expression operator expression | (expression) scalar ::= number | ‘string’ | “string” | column operator ::= AND | OR | = | <> | != | > | >= | < | <= | LIKE | NOT LIKE | MATCHES column ::= name | name.name
Currently OQL does not support LIMIT, ORDER, GROUPBY, COUNT, SUM, and many other functions
You still have unanswered questions ? Ask us.
Join our community of users to share your knowledge and good practices.