| General Information | |
| Operator | contents |
| Syntax | contents expr |
| Type | unary |
| Operand Types | oid or object collection |
| Result Type | a collection of objects |
| Functions | returns the contents of an object collection |
| Expression Examples | |
| contents(p0.children) | an array of Person oids |
| select contents(x.children) from Person x | returns a list of arrays of Person oids. |
| contents(list(1, 2, 3)) | raises an error: oid or object expected, got list |
| General Information | |
| Operator | in |
| Syntax | expr in expr |
| Type | binary |
| Operand Types | first operand: any type, second operand: oid or object collection |
| Result Type | boolean |
| Functions | returns true if the first operand belongs to the collection pointed by the second operand; false otherwise |
| Expression Examples | |
| first(select Person.name = NULL) in p0.children | returns true if the first Person instance whose name is unitialized is in the array of children of the first Person |
| first(select Car.brand = "renault") in p0.cars | returns true if the first Car instance whose brand equals renault is in the set of cars of the first Person |
| General Information | |
| Operator | add/to |
| Syntaxes | add expr to expr |
| Type | binary |
| Operand Types | first operand: any type, second operand: oid or object unorderered collection (set or bag) |
| Result Type | type of the first operand |
| Functions | adds the first operand to the non-indexed collection (i.e. bag or set) pointed by the second operand; returns the first operand. |
| Expression Examples | |
| add new Car(num : 100) to p0.cars | returns the created Car oid |
| add new Person(name : "john") to p0.children | raises an error: cannot used non indexed insertion in an array |
| add new Car() to new set<Car *>() | returns the just created car; but we have lost the oid of the just created set of cars! |
| add new Person() to (c := new bag<Person *>()) | returns the just created person; the created bag has been kept in the OQL variable c |
| General Information | |
| Operator | [] |
| Syntaxes | expr [ expr ] |
| Type | binary |
| Operand Types | first operand: collection array or list, second operand: integer |
| Result Type | the type of the element, |
| Functions | gets the element in the collection pointed by the first operand at the position pointed by the second operarand. If used at a left value, gets a reference to that element. |
| Expression Examples | |
| p0.children[0] | returns the child at position #0 in p0.children collection. Returns nil if there is no child at this position |
| p0.children[0] := Person(name : "john") | returns the created Person oid |
| p0.children[12039] := Person(name : "henry") | returns the created Person oid. This expression is valid in any cas as the collection arrays automatically increased its size |
| (array<Person *>())[0] := new Car(num : 100) | returns the just created person; but the created array has been ``lost'' as it is not tied to any instance and as we did not bind it to any OQL variable |
| (c := array<Person *>())[0] := new Car(num : 100) | returns the just created person; the created array has been kept in the OQL variable c |
| p0.cars[1] := Car(num : 100) | raises an error: array expected, got set |
| General Information | |
| Operator | [:] |
| Syntaxes | expr [ expr : expr ] |
| Type | ternary |
| Operand Types | first operand: collection array or list, second and third operands: integer |
| Result Type | the type of the element, |
| Functions | gets the elements in the collection pointed by the first operand at the position range pointed by the second and third operarands. If used at a left value, gets references to that elements. |
| Expression Examples | |
| p0.children[0:1] | returns a set of struct including the children and the position of the children position #0 and #1 in the p0.children collection. For instance: set(struct(index : 0, value : 3874.33.293847:oid), struct(index : 1, value : 2938.33.1928394:oid)) |
| Returns nil if there is no child at these positions | |
| p0.children[0:4] := Person(name : "john") | Sets all the children at the position #0 to #4 to a new Person instance. |
| returns the created Person oid | |
| p0.children[12000:12039] := Person(name : "henry") | returns the created Person oid. This expression is valid in any cas as the collection arrays automatically increased its size |
| (array<Person *>(list(Person())))[0] | returns the just created person within the just created array. But the array is ``lost'' as it is not tied to any instance and as we did not bind it to any OQL variable |
| (x := array<Person *>(list(Person())))[0] | returns the just created person; the created array has been kept in the OQL variable c |
| General Information | |
| Operator | [?] |
| Syntaxes | expr [?] |
| Type | unary |
| Operand Type | collection array or list, |
| Result Type | a set of struct or a set of references |
| Functions | gets all the elements in the collection pointed by the first operand If used at a left value, gets references to that elements. |
| Expression Examples | |
| p0.children[?] | returns a set of struct including the children and the position of all the children in the p0.children collection. For instance: set(struct(index : 0, value : 3874.33.293847:oid), struct(index : 1, value : 2938.33.1928394:oid)) |
| Returns nil if the collection is empty | |
| p0.children[?] := Person(name : "john") | Sets all the children to a new Person instance. |
| returns the created Person oid | |
| (array<Person *>(list(Person(), Person())))[?] | returns a set of struct including the just created Person instances in the just created array. |
| General Information | |
| Operator | append |
| Syntaxes | append expr to expr |
| Type | binary |
| Operand Types | first operand: any type, second operand: oid or object denoting an ordered collection |
| Result Type | any type |
| Functions | appends the element denoted by the first operand to the indexed collection (i.e. list or array) denoted by the second operand. |
| Expression Examples | |
| append Person() to p0.children | the created Person instance |
| append Car()to p0.cars | raises an error: array or list expected, got set<Person*> |
| General Information | |
| Operator | suppress/from |
| Syntaxes | suppress expr from expr |
| Type | binary |
| Operand Types | first operand: any type, second operand: oid or object collection |
| Result Type | type of the first operand |
| Functions | suppress the first operand from the non-indexed collection (i.e. bag or set) pointed by the second operand; returns the first operand. |
| Expression Examples | |
| suppress (select Car.num = 1000) from p0.cars | the suppressed car if it was found in the collection; otherwise, raises an error |
| suppress new Car() from p.cars | raises an error: item '71238.13.3959935:oid' not found in collection |
| suppress p0 from p0.children | raises an error: cannot used non indexed suppression in an array |
| General Information | |
| Operator | empty |
| Syntax | empty expr |
| Type | unary |
| Operand Types | oid or object collection |
| Result Type | nil |
| Functions | empty the collection pointed by the operand |
| Expression Examples | |
| empty(first (select Person).children) | nil |
| empty(first (select Person).cars) | nil |
| empty new set<Car *>(list(new Car())) | nil; this expression creates a collection of Car containing initially a new Car, and empty it! |
| General Information | |
| Operator | exists/in |
| Syntax | exists identifier in expr : expr |
| Type | ternary |
| Operand Types | first operand: identifier, second operand: oid or object collection, third operand: boolean |
| Result Type | boolean |
| Functions | returns true if it exists in the collection pointed by the second operand an element for which the third operand is evaluated to true. |
| Expression Examples | |
| exists x in p0.children: x.name = "mary" | true or false |
| exists x in p0.cars: x.num < 100 and x.num >= 90 | true or false |
| General Information | |
| Operator | for/all |
| Syntaxes | for all identifier in expr : expr |
| Type | ternary |
| Operand Types | first operand: identifier, second operand: oid or object collection, third operand: boolean |
| Result Type | boolean |
| Functions | returns true if for all items contained in the collection pointed by the second operand the third operand is evaluated to true. |
| Expression Examples | |
| for all x in p0.children: x.name == "john" | true or false |
| for all x in p0.cars: x.num % 10 | true or false |
| General Information | |
| Operator | forcardinality |
| Syntaxes | for < expr : expr > identifier in expr : expr |
| for < expr > identifier in expr : expr | |
| Type | 5-ary |
| Operand Types | first and optional second operands: integer or $, where $ denotes the collection cardinality, third operand: oid or object, fourth operand: identifier, fifth operand: boolean |
| Result Type | boolean |
| Functions | returns true if the number of items in the collection pointed by the third operand for which the third operand is evaluated to true is in the interval [first operand, second operand]. |
| Expression Examples | |
| for <0:4> x in p0.children: x.name == "john" | true if at most 4 children have their name equals to john |
| for <4> x in p0.children: x.name == "john" | true if one an only one children have its name equals to john |
| for <0:$> x in p0.cars: x.num = 10 | equivalent to exists/in |
| for <$> x in p0.cars: x.num = 10 | equivalent to for/all |