You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/marketplace/platform-supported-content/modules/oql-module.md
+44-23Lines changed: 44 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,15 @@ description: "Describes the configuration and usage of the OQL module, which is
6
6
7
7
## Introduction
8
8
9
-
The [OQL Module](https://marketplace.mendix.com/link/component/66876)executes [OQL](https://docs.mendix.com/refguide/oql/) queries and returns the results as a list of Mendix objects, a count of results in the database or a CSV file.
9
+
The [OQL Module](https://marketplace.mendix.com/link/component/66876)adds microflow actions which execute [OQL](https://docs.mendix.com/refguide/oql/) queries and return the results as a list of Mendix objects, a count of results in the database, or a CSV file. This means that you do not need to write your own Java actions to execute OQL queries.
10
10
11
11
### Typical Use Cases
12
12
13
-
This module allows users to run arbitrary OQL queries without having to write Java code.
14
-
It is also an alternative to [View Entities](/refguide/view-entities/) with support for running dynamic OQL queries and using OQL parameters.
15
-
Unless these features are necessary, it is recommended to use View Entities.
13
+
This module allows users to run OQL queries directly from a string or from a [dataset](/refguide/data-sets/) without having to write Java code.
16
14
17
-
Alternatively, this module can be used to interactively investigate data problems in a running app.
15
+
It is also an alternative to [View Entities](/refguide/view-entities/) where you need support for running dynamic OQL queries and using OQL parameters. Unless these features are necessary, Mendix recommends that you use View Entities.
16
+
17
+
You can also use this module to interactively investigate data problems in a running app.
18
18
19
19
{{% alert color="warning" %}}
20
20
The OQL Module does not validate the input query and does not apply user role access controls when executing queries.
@@ -23,58 +23,72 @@ Care should be taken to guarantee that the query is valid and does not expose ap
23
23
24
24
### Features
25
25
26
-
* Execute an OQL query directly or load a query from a dataset
26
+
The OQL module has the following features:
27
+
28
+
* Executes an OQL query directly or loads a query from a dataset
27
29
* Supports running queries with limit and offset
28
30
* Supports OQL named query parameters
29
-
* Option to return data directly or generate a CSV file
30
-
* Option to compress the generated CSV file in a Zip file
31
-
* Customize CSV files to use different characters for quoting strings, separating values, and escaping special characters
32
-
* Customize CSV files to remove new line sequences from string values
31
+
* Returns data directly or generates a CSV file
32
+
* If you opt to generate a CSV file, this can be created with the following characteristics:
33
+
* Compressed in a Zip file
34
+
* Customized to use different characters for quoting strings, separating values, and escaping special characters
35
+
* Customized to remove new line sequences from string values
33
36
34
37
## Available OQL Actions
35
38
36
-
All actions support defining [Named Parameters](#named-parameters) for queries.
37
-
Only `SELECT` queries are supported and all queries are executed without access rules.
39
+
{{% alert color="info" %}}
38
40
39
-
### ExecuteOQLStatement {#executeoqlstatement}
41
+
* Only `SELECT` queries are supported
42
+
* All actions support defining named parameters for queries – see [Named Parameters](#named-parameters), below, for more information
43
+
* All queries are executed without access rules
44
+
45
+
{{% /alert %}}
40
46
41
-
This action executes an OQL query, either directly or by loading one from a dataset. If you wish to use a dataset, you need to provide its fully qualified name (example "MyFirstModule.Dataset", instead of just "Dataset").
47
+
### ExecuteOQLStatement {#executeoqlstatement}
42
48
43
-
Returns: A list of Mendix objects of type `returnEntity` with each query column stored in an attribute or association of the same name. Note:
44
-
- Attributes and associations of the `returnEntity` that are not present in the query are ignored
45
-
- Only associations owned by the `returnEntity` are considered when setting associations
49
+
This action executes an OQL query, either directly or by loading one from a dataset. If you wish to use a dataset, you need to provide its fully-qualified name (for example "MyFirstModule.Dataset", rather than just "Dataset").
46
50
47
51
This action takes the following parameters:
52
+
48
53
*`statement`: OQL Query or fully qualified name of a Dataset (module and Dataset name) to be executed
49
54
*`returnEntity`: Entity type to be used to store results
50
55
*`amount`: If not `empty` or 0, will limit the number of results to at most this amount. It is recommended to use an explicit sorting order in the OQL query when using amount
51
56
*`offset`: If not `empty` or 0, will offset the results of the query by this quantity. It is recommended to use an explicit sorting order in the OQL query when using offset
52
57
*`preserveParameters`: If false, all parameters defined for this query will be cleared
Similar to `ExecuteOQLStatement` above, but returns only the number of results. Useful to obtain information from the database without the overhead of generating Mendix objects.
61
+
* A list of Mendix objects of type `returnEntity` using the following rules:
62
+
* Each query result column is stored in an attribute or association of the same name
63
+
* Attributes and associations of the `returnEntity` that are not present in the query are given the default value
64
+
* Only associations owned by the `returnEntity` are considered when setting associations
Returns: The number of resultsof executing `statement`
68
+
Similar to `ExecuteOQLStatement`, above, but returns only the number of results. Use this to obtain information from the database without the overhead of generating Mendix objects.
59
69
60
-
This action does not support datasets
70
+
This action does not support datasets.
61
71
62
72
[Named parameters](#named-parameters) are always reset on completion.
63
73
64
74
This action takes the following parameters:
75
+
65
76
*`statement`: OQL Query to be executed
66
77
*`amount`: Limits the number of results to at most this amount. If there are more results in the query than this limit, this amount is returned instead. If set to 0, no limit is applied
67
78
*`offset`: This parameter is ignored and might be removed in a future version
68
79
80
+
It returns the following:
81
+
82
+
* The number of results of executing `statement`
83
+
69
84
### ExportOQLToCSV {#exportoqltocsv}
70
85
71
86
This action executes an OQL query and saves the result in a CSV file.
72
87
73
-
Returns: An object of type `FileDocument` (or a specialization of it) containing the CSV file with the results of executing `statement`
74
-
75
88
[Named parameters](#named-parameters) are always reset on completion.
76
89
77
90
This action takes the following parameters:
91
+
78
92
*`statement`: OQL Query or fully qualified name of a Dataset (module and Dataset name) to be executed
79
93
*`returnEntity`: A FileDocument or one of its specializations where the resulting file will be stored
80
94
*`removeNewLinesFromValues`: Indicates if new lines inside string values should be replaced with spaces
@@ -84,14 +98,21 @@ This action takes the following parameters:
84
98
*`quoteChar`: Indicates what character should be used to quote string values. May be left empty if `escapeChar` is defined
85
99
*`escapeChar`: Indicates what character should be used to escape spaces and other special characters if string values are unquoted. Only applicable if `escapeChar` is not defined
86
100
101
+
It returns the following:
102
+
103
+
* An object of type specified in the `returnEntity` parameter containing the CSV file with the results of executing `statement`
104
+
87
105
## Named Parameters {#named-parameters}
88
106
89
107
If you wish to use named parameters inside an OQL query, you must call the following actions to set their values before calling the actions above:
108
+
90
109
*`AddBooleanParameter`: For Boolean parameters
91
110
*`AddDateTimeParameter`: For Date and Time parameters
92
111
*`AddDecimalParameter`: For parameters of type Decimal
93
112
*`AddIntegerLongValue`: For parameters of type Integer/Long
94
113
*`AddObjectParameter`: For parameters that reference a Mendix Object
95
114
*`AddStringParameter`: For String parameters
96
115
116
+
{{% alert color="info" %}}
97
117
If you wish to keep the same parameters across multiple calls to the [ExecuteOQLStatement](#executeoqlstatement) action, you must set `preserveParameters` to `true`. All other OQL actions above will clear all defined parameters after every call.
0 commit comments