Skip to content

Commit b95cdd6

Browse files
committed
Proofread and clarify versions
1 parent b6b0d02 commit b95cdd6

1 file changed

Lines changed: 60 additions & 31 deletions

File tree

content/en/docs/refguide/modeling/domain-model/oql/oql-statements.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ The `execute()` method returns the number of objects that were affected by the s
4747

4848
## `DELETE` Statement {#oql-delete}
4949

50+
{{% alert color="info" %}}
51+
Available from Mendix version 11.1.0
52+
{{% /alert %}}
53+
5054
The syntax of `DELETE` statements is:
5155

5256
```sql
5357
DELETE FROM <entity> WHERE <condition>
5458
```
5559

56-
`condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where).
60+
* `entity` is the entity whose objects are being deleted.
61+
* `condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where).
5762

5863
### OQL `DELETE` Limitations
5964

@@ -63,21 +68,39 @@ DELETE FROM <entity> WHERE <condition>
6368

6469
## `UPDATE` Statement {#oql-update}
6570

71+
{{% alert color="info" %}}
72+
Available from Mendix version 11.3.0
73+
{{% /alert %}}
74+
6675
The syntax of `UPDATE` statements is:
6776

6877
```sql
6978
UPDATE <entity>
70-
SET { { <attribute> | <association> } = <expression> } [ ,...n ]
79+
SET { { <attribute> | <association> } = <expression> } [ ,n ]
7180
WHERE <condition>
7281
```
7382

74-
`entity` is the entity whose objects are being updated.
83+
* `entity` is the entity whose objects are being updated.
84+
85+
* `attribute` is an attribute of the entity that is being updated.
7586

76-
`attribute` is an attribute of the entity that is being updated. `association` is an association that is being updated. Multiple attributes and associations can be updated in the same statement. An attribute of type `autonumber` can not be updated. The `ID` field of an entity cannot be updated.
87+
An attribute of type `autonumber` can not be updated. The `ID` attribute of an entity cannot be updated.
7788

78-
`expression` is a new value of an attribute or association. Any [OQL expression](/refguide/oql-expressions/) is allowed. When updating attributes, the value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion). When updating an enumeration attribute using a literal, the literal must be a valid value for the enumeration. When updating an enumeration attribute using another enumeration, the expression enumeration must be a subset of the attribute enumeration. When updating a string attribute using a string literal, the literal length must be equal to or less than the length of the attribute. In the case of associations, association and entity expressions must match the target association type. Values of type LONG can also be used as association values, but they must be valid ids of associations which are of the target association type.
89+
* `association` is an association that is being updated. Associations can be updated in Mendix version 11.4.0 and above.
7990

80-
`condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where).
91+
Multiple attributes and associations can be updated in the same statement.
92+
93+
* `expression` is a new value of an attribute or association. Any [OQL expression](/refguide/oql-expressions/) is allowed.
94+
95+
* When updating attributes, the value type of the expression should match the attribute type according to [type coercion precedence](/refguide/oql-expression-syntax/#type-coercion).
96+
* When updating an enumeration attribute using a literal, the literal must be a valid value for the enumeration.
97+
* When updating an enumeration attribute using another enumeration, the expression enumeration must be a subset of the attribute enumeration.
98+
* When updating a string attribute using a string literal, the literal length must be equal to or less than the length of the attribute.
99+
* In the case of associations, association and entity expressions must match the target association type.
100+
101+
Values of type LONG can also be used as association values, but they must be valid ids of associations which are of the target association type.
102+
103+
* `condition` can be anything that can appear in an OQL [WHERE clause](/refguide/oql-clauses/#where).
81104

82105
Example:
83106

@@ -141,40 +164,23 @@ SET
141164
SpecializationAttribute = 1
142165
```
143166

144-
## Joins
145-
146-
You cannot directly join other entities in the `FROM` clause of OQL `DELETE` or in the `UPDATE` clause of OQL `UPDATE`. However, you can achieve the same result using long paths or subqueries. For example:
147-
148-
```sql
149-
DELETE FROM Module.Order
150-
WHERE Module.Order_Customer/Module.Customer/Name = 'Mary'
151-
```
152-
153-
or
154-
155-
```sql
156-
UPDATE Module.Order
157-
SET CustomerName = 'Mary'
158-
WHERE ID IN (
159-
SELECT ID
160-
FROM Module.Order
161-
INNER JOIN Module.Customer ON Module.Customer/CustomerID = Module.Order/CustomerID
162-
WHERE Module.Customer/Name = 'Mary' )
163-
```
164-
165167
## `INSERT` Statement {#oql-insert}
166168

169+
{{% alert color="info" %}}
170+
Available from Mendix version 11.6.0
171+
{{% /alert %}}
172+
167173
The syntax of `INSERT` statements is:
168174

169175
```sql
170-
INSERT INTO <entity> ( <attribute> [ ,...n ] ) <oql-query>
176+
INSERT INTO <entity> ( <attribute> [ ,n ] ) <oql-query>
171177
```
172178

173-
`entity` is the entity for which new objects will be created.
179+
* `entity` is the entity for which new objects will be created.
174180

175-
`attribute` is an attribute of the entity that will be inserted.
181+
* `attribute` is an attribute of the entity that will be inserted.
176182

177-
`oql-query` is any OQL query that returns same number of columns as the number of attributes that will be inserted.
183+
* `oql-query` is any OQL query that returns same number of columns as the number of attributes that will be inserted.
178184
This query can select data from persistable entities and/or [view entities](/refguide/view-entities/).
179185

180186
Example:
@@ -198,3 +204,26 @@ SELECT NewOrderNumber, Loader.TemporaryData_Customer/Loader.Customer/Number FROM
198204
* Entity access rules are not applied to any OQL statements.
199205
* No event handlers will be executed.
200206
* Runtime and client state will not be updated with the changes.
207+
208+
### Joins
209+
210+
You cannot directly join other entities in the `FROM` clause of OQL `DELETE` or in the `UPDATE` clause of OQL `UPDATE`. However, you can achieve the same result using long paths or subqueries. For example:
211+
212+
```sql
213+
DELETE FROM Module.Order
214+
WHERE Module.Order_Customer/Module.Customer/Name = 'Mary'
215+
```
216+
217+
or
218+
219+
```sql
220+
UPDATE Module.Order
221+
SET CustomerName = 'Mary'
222+
WHERE ID IN (
223+
SELECT ID
224+
FROM Module.Order
225+
INNER JOIN Module.Customer ON Module.Customer/CustomerID = Module.Order/CustomerID
226+
WHERE Module.Customer/Name = 'Mary' )
227+
```
228+
229+

0 commit comments

Comments
 (0)