Changes for page DB-Abfragen


From version 6.1
edited by jdr
on 19.07.2021, 14:11
Change comment: There is no comment for this version
To version 1.1
edited by XIMA Admin
on 20.01.2021, 16:22
Change comment: Imported from XAR

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.jdr
1 +XWiki.ximaadmin
Content
... ... @@ -12,6 +12,17 @@
12 12  {{figure image="data_db_query_de.png"}}Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.{{/figure}}
13 13  
14 14  
15 +{{html wiki="true"}}
16 +<div class='xm-figure xm-float-right xm-clear-h2' data-alt='Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.'><div class='xm-figure-inner' style='width:310px'>{{lightbox image='data_db_query_de.png' width='300' group='$height' group='$group' title='Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.'/}}<div class='xm-figure-caption'>Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.</div></div></div>
17 +{{/html}}
18 +
19 +
20 +
21 +{{html wiki="true"}}
22 +<div class='xm-figure xm-float-right xm-clear-h2' data-alt='Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.'><div class='xm-figure-inner' style='width:310px'>{{lightbox image='data_db_query_de.png' width='300' group='$height' group='$group' title='Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.'/}}<div class='xm-figure-caption'>Configuration screen for creating a database query in: (1) list of existing DB queries, (2) editor for defining the SQL query, (3) settings of the DB query, (4) console for testing the DB query.</div></div></div>
23 +{{/html}}
24 +
25 +
15 15  * Open the module "Database queries" and click "New" {{ficon name="plus-circle-outline"/}} in the header of the list (see [[figure>>||anchor="fig_data_db_query"]]).
16 16  * The following data is needed for a Database query:
17 17  ** **Name**: A unique name for the database query
... ... @@ -22,7 +22,7 @@
22 22  
23 23  The entered SQL statement is executed as a prepared statement, which prevents SQL injection attacks. You should not and need not use inverted commas (` or '). Also, you can use question marks ( ? ) as placeholders to build queries dynamically.
24 24  
25 -[[Variables>>doc:Formcycle.UserInterface.Variables.WebHome]] can be used in the SQL statements.
36 +{{version major="6" minor="4" patch="0"/}} [[Variables>>doc:Formcycle.UserInterface.Variables.WebHome]] can be used in the SQL statements.
26 26  
27 27  == Using the database query ==
28 28  
... ... @@ -44,7 +44,7 @@
44 44  |queryParameter|When the query contains placeholders (question marks, {{code language="none"}}?{{/code}}), a list of parameters must be supplied for each placeholder. The number of items must match the number of parameters used in the SQL query. The items are separated with the delimiter as defined by the URL parameter //delimiter//.
45 45  
46 46  If possible the parameter //queryParameterValues// should be used for new projects instead of //queryParameter// because //queryParameter// will not be supported in a future version of {{formcycle/}}.|No
47 -|queryParameterValues|Starting with {{formcycle/}} Version 6.6.3 this parameter can be used as an alternative to the parameters //queryParameter// and //delimiter//. Like these parameters, //queryParameterValues// is only required if placeholders in the form of a question mark {{code language="none"}}?{{/code}} are used within the SQL query. If this is the case, the individual query parameters are passed one after the other as a separate parameter //queryParameterValues//, which also eliminates the use of the parameter //delimiter//.|No
58 +|queryParameterValues|{{version major="6" minor="6" patch="3"/}}Starting with {{formcycle/}} Version 6.6.3 this parameter can be used as an alternative to the parameters //queryParameter// and //delimiter//. Like these parameters, //queryParameterValues// is only required if placeholders in the form of a question mark {{code language="none"}}?{{/code}} are used within the SQL query. If this is the case, the individual query parameters are passed one after the other as a separate parameter //queryParameterValues//, which also eliminates the use of the parameter //delimiter//.|No
48 48  |varName|Allows you to change name of the JSON response object. If not given, a plain JSON object with the result data is returned.|No
49 49  |delimiter|The delimiter for the placeholder values, see //queryParameter//. Defaults to a comma {{code language="none"}},{{/code}}
50 50  
... ... @@ -51,7 +51,7 @@
51 51  If possible the parameter //queryParameterValues// should be used for new projects instead of //delimiter// and //queryParameter// because //delimiter// will not be supported in a future version of {{formcycle/}}.|No
52 52  {{/table}}
53 53  
54 -When accessing a database servlet from a form, always use the database URL contained in the global object //XFC_METADATA//, see also the [[metadata>>doc:Formcycle.Designer.Form.CodingPanel.ScriptTab.FormMetadata]]. For example: {{code language="javascript"}}XFC_METADATA.urls.datasource_db{{/code}}.
65 +When accessing a database servlet from a form, always use the database URL contained in the global object //XFC_METADATA//, see also the [[metadata>>doc:Formcycle.FormDesigner.CodingPanel.ScriptTab.FormMetadata]]. For example: {{code language="javascript"}}XFC_METADATA.urls.datasource_db{{/code}}.
55 55  
56 56  Further we recommend you use the script function {{jsdoc page="xutil" name="getdataquery"/}}, so you do not have to setup the servlet request manually. The result of the database query is returned as //JSON//.
57 57  
... ... @@ -79,7 +79,7 @@
79 79  
80 80  == Selection form elements ==
81 81  
82 -If you want to display the returned data as options of a [[selection element>>doc:Formcycle.Designer.Form.FormElements.Selection]], you can do so easily by opening the {{designer/}} and selecting the database query as the data source of the selection element.
93 +If you want to display the returned data as options of a [[selection element>>doc:Formcycle.FormDesigner.FormElements.Selection]], you can do so easily by opening the {{designer/}} and selecting the database query as the data source of the selection element.
83 83  
84 84  {{info}}
85 85  Queries that are used in selection elements must not have a question mark "?". Queries with a "?" are not offered as a data source for selection elements.
... ... @@ -89,7 +89,7 @@
89 89  Using the result of a database query as the data source a select element in the {{designer case="dat"/}}.
90 90  {{/figure}}
91 91  
92 -The result of the database query is used to create the options of the [[selection element>>doc:Formcycle.Designer.Form.FormElements.Selection]] in the following order:
103 +The result of the database query is used to create the options of the [[selection element>>doc:Formcycle.FormDesigner.FormElements.Selection]] in the following order:
93 93  
94 94  {{box}}
95 95  Displayed value, submitted value, optional value 1, optional value 2, ...
... ... @@ -107,6 +107,11 @@
107 107  
108 108  == Examples ==
109 109  
121 +{{info}}
122 +{{version major="6" minor="6" patch="3"/}}Starting with {{formcycle/}} Version 6.6.3, the parameter //queryParameterValues// can be used instead of the parameter //queryParameter//. The former is recommended for new projects because the parameter //queryParameter// will not be supported in a future version of {{formcycle/}}. The following examples therefore show one servlet query with //queryParameter// and one with //queryParameterValues// for each SQL query.
123 +{{/info}}
124 +
125 +
110 110  {{code language="sql"}}
111 111  select name, first_name from table where first_name like (?)
112 112  {{/code}}
... ... @@ -114,6 +114,9 @@
114 114  This SQL statement returns the names of all persons with a certain first name. The first name to search for is specified via an URL parameter.
115 115  
116 116  URL for running the query:
133 +{{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameter=Robinson{{/code}}
134 +
135 +{{version major="6" minor="6" patch="3"/}}URL that can be used starting with {{formcycle/}} version 6.6.3 for running the query:
117 117  {{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameterValues=Robinson{{/code}}
118 118  \\
119 119  
... ... @@ -124,6 +124,9 @@
124 124  Retrieves the name of a person with a certain ID. The ID is given as an URL parameter.
125 125  
126 126  URL for running the query:
146 +{{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameter=100{{/code}}
147 +
148 +{{version major="6" minor="6" patch="3"/}}URL that can be used starting with {{formcycle/}} version 6.6.3 for running the query:
127 127  {{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameterValues=100{{/code}}
128 128  \\
129 129  
... ... @@ -134,6 +134,9 @@
134 134  Retrieves the names of all persons that live in certain city. The city and the ZIP code are given as URL parameters.
135 135  
136 136  URL for running the query:
159 +{{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameter=Paris,75001{{/code}}
160 +
161 +{{version major="6" minor="6" patch="3"/}}URL that can be used starting with {{formcycle/}} version 6.6.3 for running the query:
137 137  {{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameterValues=Paris&queryParameterValues=75001{{/code}}
138 138  \\
139 139  
... ... @@ -144,6 +144,9 @@
144 144  This SQL statement returns the names of all persons who live in a place that **starts **with the given characters. The '%' character serves as a wildcard for any number of characters. Depending on the DBMS used, the syntax may differ slightly (here: MySQL). The requested value is passed via URL parameters.
145 145  
146 146  URL for running the query:
172 +{{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameter=Par{{/code}}
173 +
174 +{{version major="6" minor="6" patch="3"/}}URL that can be used starting with {{formcycle/}} version 6.6.3 for running the query:
147 147  {{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameterValues=Par{{/code}}
148 148  \\
149 149  
... ... @@ -154,4 +154,7 @@
154 154  This SQL statement returns the names of all persons who live in a place that **contains **the given characters. Upper/lower case spelling is irrelevant becauce the statement converts both, the value column and the actual filter value to lower case (lower(...)). The requested value is passed via URL parameters.
155 155  
156 156  URL for running the query:
185 +{{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameter=aRi{{/code}}
186 +
187 +{{version major="6" minor="6" patch="3"/}}URL that can be used starting with {{formcycle/}} version 6.6.3 for running the query:
157 157  {{code language="none"}}http://myserver/formcycle/datenquelledb?mandantName=myself&name=demo&queryParameterValues=aRi{{/code}}