Skip to content

Commit d97ed1f

Browse files
committed
Document new OQL feature: INSERT ... VALUES
1 parent 391b0b8 commit d97ed1f

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,16 @@ SET
157157
## `INSERT` Statement {#oql-insert}
158158

159159
{{% alert color="info" %}}
160-
Available from Mendix version 11.6.0
160+
Available from Mendix version 11.6.0 when sourcing data from an oql query.
161+
Available from Mendix version 11.13.0 when using `VALUES` to specify rows directly.
161162
{{% /alert %}}
162163

163-
The syntax of `INSERT` statements is:
164+
`INSERT` statements can be written with values or queries.
165+
166+
### `INSERT` with query
164167

165168
```sql
166-
INSERT INTO <entity> ( <attribute | <association> [ , …n ] ) <oql-query>
169+
INSERT INTO <entity> ( <attribute> | <association> [ , …n ] ) <oql-query>
167170
```
168171

169172
* `entity` is the entity for which new objects will be created.
@@ -182,6 +185,27 @@ INSERT INTO Module.Order ( OrderNumber, CustomerNumber, Module.Order_Customer )
182185
SELECT NewOrderNumber, Loader.TemporaryData_Customer/Loader.Customer/Number, Loader.TemporaryData_Customer FROM Loader.TemporaryData
183186
```
184187

188+
### `INSERT` with `VALUES`
189+
190+
```sql
191+
INSERT INTO <entity> ( <attribute> [ , …n ] ) VALUES (<expression 1> [, …<expression n>]) [ …, (<expression 1> [, …<expression n>])]
192+
```
193+
194+
* `entity` is the entity for which new objects will be created.
195+
196+
* `attribute` is an attribute of the entity that will be inserted.
197+
198+
* `expression n` is any valid OQL expression with literals or OQL parameters.
199+
Every row must contain the same number of values of compatible types.
200+
This query can *not* select data from any entities.
201+
202+
Example:
203+
204+
```sql
205+
INSERT INTO Module.Order ( OrderNumber, CustomerNumber )
206+
VALUES ( 1, 32 ), ( 2, 33 ), ( $LastOrderNumber + 1, $CustomerNumber )
207+
```
208+
185209
### OQL `INSERT` Limitations
186210

187211
* Only a single value can be specified per association.

0 commit comments

Comments
 (0)