Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:2000_concepts:0600_data_retrieval:0100_config_queries [2022/09/01 01:23] – ↷ Links adapted because of a move operation administrator | docs:2000_concepts:0600_data_retrieval:0100_config_queries [2026/07/09 10:22] (current) – aware_admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | {{tag> | ||
| [< | [< | ||
| ====== Configuring Queries ====== | ====== Configuring Queries ====== | ||
| - | Queries | + | AwareIM |
| + | There are three types of queries as far as search criteria is concerned: | ||
| + | - Those that use search criteria compatible with the '' | ||
| + | - Queries that use stored prcedures and map to the '' | ||
| + | - Queries that use the SQL SELECT statement and map to the '' | ||
| + | |||
| + | Standard queries should be suitable for most needs. However, some complex queries may require stored procedures or raw SQL. When configurators create a new query, they specify whether they want a standard query a stored procedure or an SQL SELECT statement. | ||
| + | |||
| + | The concept of a query in **AwareIM** includes both data search criteria and a particular presentation of the found data to the user (grid, calendar, chart, tree etc). Irrespective of the implementation the options for data presentation are for the most part the same - whether it's a standard query, a stored procedure or raw SQL. | ||
| - | When defining a query the configurator has to indicate the business object, (or [[docs: | + | When defining a query, the configurator has to indicate the business object, (or [[docs: |
| - | <code aim> FIND Account WHERE Account.OwnerName = 'John Smith'</ | + | The next step when defining a query is to indicate the conditions of search – only those instances of the business object that have attribute values matching the specified conditions will be retrieved by the query. for queries implemented as stored procedures or SQL SELECT statements, this step is done inside the stored procedure or SQL itself. For standard queries conditions of the search can be specified using Query Builder View as explained below or as part of the FIND action (if working in the Textual View) |
| + | |||
| + | ===== Using Query Builder to Define Standard Queries ===== | ||
| + | |||
| + | For standard queries conditions of the search can be specified using the Query Builder. If conditions are not specified all instances of the business object will be retrieved. For example, if a query is to retrieve accounts of John Smith, the query has to include a condition that compares the value of the '' | ||
| + | |||
| + | <code aim>FIND Account WHERE Account.OwnerName = 'John Smith' </ | ||
| One can define multiple conditions for a query – the conditions may be linked with the '' | One can define multiple conditions for a query – the conditions may be linked with the '' | ||
| Line 12: | Line 27: | ||
| Note that query conditions allow specifying not only attributes of the business object that the query will be searching, but also attributes of the related objects. For example, if account owner is a '' | Note that query conditions allow specifying not only attributes of the business object that the query will be searching, but also attributes of the related objects. For example, if account owner is a '' | ||
| - | <code aim> FIND Account WHERE Account.Owner.Name = 'John Smith' </ | + | <code aim>FIND Account WHERE Account.Owner.Name = 'John Smith' |
| It is also possible to indicate attributes of objects related to the related objects, for example, '' | It is also possible to indicate attributes of objects related to the related objects, for example, '' | ||
| Line 25: | Line 39: | ||
| <callout type=" | <callout type=" | ||
| - | <code aim>FIND Account WHERE Account.OwnerName = Customer.Name</ | + | <code aim>FIND Account WHERE Account.OwnerName = Customer.Name </ |
| - | The business object Customer used in a query condition is not the object that the query is searching for. //**Aware IM**// replaces references to such attributes with the actual values at run time – just before the search is performed. For example, if the value of the Name attribute of the Customer object is ‘John Smith’ the actual query performed by //**Aware IM**// is: | + | The business object Customer used in a query condition is not the object that the query is searching for. //**AwareIM**// replaces references to such attributes with the actual values at run time – just before the search is performed. For example, if the value of the Name attribute of the Customer object is ‘John Smith’ the actual query performed by //**AwareIM**// is: |
| - | <code aim>FIND Account WHERE Account.OwnerName = 'John Smith'</ | + | <code aim>FIND Account WHERE Account.OwnerName = 'John Smith' </ |
| - | Where does //**Aware IM**// find the instance of the Customer object and what happens if there are no instances of this object or if there are more than one instance? The answer to the first part of the question is that the instance is taken from the Context (this is explained in the [[docs: | + | Where does //**AwareIM**// find the instance of the Customer object and what happens if there are no instances of this object or if there are more than one instance? The answer to the first part of the question is that the instance is taken from the Context (this is explained in the [[docs: |
| See also [[docs: | See also [[docs: | ||
| </ | </ | ||
| + | ===== Defining Queries Implemented as Stored Procedures===== | ||
| + | As explained before, queries implemented as stored procedures refer to a particular stored procedure defined in the AwareIM database. When such queries execute, **AwareIM** automatically executes the related stored procedure providing values of parameters if required. The results of the stored procedure are then presented to the user as defined by the query - either as a grid, a calendar or a chart. The query follows the format of the '' | ||
| + | |||
| + | < | ||
| + | This query is implemented as a stored procedure called " | ||
| + | |||
| + | < | ||
| + | This stored procedure has two parameters - the second is hardcoded and the first one is initialized from the object in Context (ParamObject). | ||
| + | |||
| + | <callout type=" | ||
| + | When a configurator defines a new **AwareIM** query implemented as stored procedure and the stored procedure already exists, a developer can initialize the new query from the list of stored procedures available in the database and generate an appropriate EXEC_SP statement. | ||
| + | </ | ||
| + | |||
| + | <callout type=" | ||
| + | **AwareIM** automatically provides support for dynamic paging, dynamic sorting and dynamic filtering of records returned by queries implemented as stored procedures. However, you need to know the following: | ||
| + | - Support for dynamic paging, sorting and filtering is only provided for MySQL and SQL Server databases. | ||
| + | - If a stored procedure has multiple SELECT statements, **AwareIM** needs to know which one of the SELECT statements returns records compatible with the RETURN statement of the stored procedure. To do this, enclose this SELECT statement with BEGIN MAIN SELECT and END MAIN SELECT comments, for example: | ||
| + | %%-- BEGIN MAIN SELECT%%\\ | ||
| + | %%SELECT...%%\\ | ||
| + | %%-- END MAIN SELECT%%\\ | ||
| + | </ | ||
| + | ===== Defining Queries Implemented as SQL SELECT Statements ===== | ||
| + | Queries | ||
| + | < | ||