SQL databases

Connection settings Firebird, IBM DB2, MariaDB, Microsoft Azure SQL, Microsoft SQLServer, MySQL, Oracle, PostreSQL, SQLite

▪    Basic settings: Specify the server (<Server name>
[\<Instance name>][:<Port>] and select the type of authentication.
Both SQL Server and Windows authentication are supported as methods for logging in.

Windows authentication represents the highest level of security and also uses Windows user accounts for the logging into the SQL Server.

SQL Server authentication (if such is supported by the server) will also allow external access.

▪    Expert mode: For special connection settings, you can enter the connection string manually.

Examples of connection strings:

Firebird: User=SYSDBA;Password=masterkey;Database=myDataBase.fdb; DataSource=localhost;Port=3050;Dialect=3;Charset=NONE; Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0; MaxPoolSize=50;Packet Size=8192;ServerType=0

Microsoft Azure SQL: Server=tcp:myServerName.database.windows.net; Database=myDataBase;User ID=myUsername@myServerName; Password=myPassword;Trusted_Connection=False;Encrypt=True;

Microsoft SQL Server: Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

PostgreSQL: Server=127.0.0.1;Port=5432;Database=myDataBase;User
Id=myUsername;Password=myPassword;

MySQL: Server=myServerAddress;Port=3306;Database=myDataBase; Uid=myUsername;Pwd=myPassword;

In special cases it may be necessary to increase the timeout directly in the connection string. Information about connection strings and possible parameters, see https://www.connectionstrings.com.

Example for Postgres:

Server=127.0.0.1;Port=5432;Database=myDataBase;User Id=myUsername;Password=myPassword;CommandTimeout=20;Timeout=15;

Selecting data

The database can be used as a data source in different ways.

▪    Full Database: all tables and views will be available, to which the specified connection has access.

▪    Selected tables: Only the selected tables and views are available.

▪    Single Queries: Define any number of custom SQL queries, whose results can then be used by reports.

▪    Add SQL Query: Enter the query. Test the query using the respective button. Any number of queries may be entered.

Example for a single query:

SELECT users.type,  sale.date_finished::date AS date,

SUM(sale_position.amount) AS total_amount

FROM public.sale_position, public.sale, public.users

WHERE sale.date_finished IS NOT NULL

GROUP BY sale.date_finished::date, users.type

ORDER BY users.type, date;

▪    Add Query (Assistant): With some data sources (MS SQL, Oracle, MySQL, MariaDB, PostgreSQL, SQLite), a wizard is available for creating database queries. More information on the wizard is given in the section Query-Assistant.

▪    Add Routine (Wizard): For some data sources, routines (stored procedures, table value functions) can be added with the defined parameters (including support for data source parameters). These routines can also return data and be used directly in the Report Server.

Supported data sources:

▪    MSSQL: Stored Procedures, Table-Valued Functions

▪    MySQL/MariaDB: Stored Procedures

▪    PostgreSQL: Table-Valued Functions (At least 2 columns within the table return)

▪    Oracle: Stored Procedures (table return only)

▪    Schema: With some data sources (MS SQL, Oracle, DB2), you can specify a scheme to only load tables with this scheme. Depending on the type of data source, you can also specify multiple schemes (e.g., separated by commas). Particularly in relatively large databases, this can provide a clearer overview and increase processing speed.

▪    Relations: You can define the relations between the various queries or add further relations to the automatically determined relations. The database structure will be analyzed, such that that all the user has to do is simply select the relevant tables and fields. Proceed as follows:

4.  Choose "Add Relation"

5.  Enter a table alias (relation name). This name is displayed below the 1:n linked child table beneath the parent table in the  Designer.

6.  Choose the parent table and the primary key field.

▪    Chose the child table and the foreign key field that corresponds to the primary key of the parent table.

Figure 2.18: Defining relations

Database schemas

The option "Use schema prefix for table names" is available for several databases. A database schema allows a logical separation of tables. E.g. tables with the same name can be used within the same database.

Microsoft Access connection settings

▪    Server URL: File path or URL[:Port]

▪    User name and password

▪    Database password

Query-Assistant

The Wizard for single queries is a highly flexible method of easily creating queries so that only certain types of records are available as data sources. You can define and combine any number of conditions and also group conditions. The Wizard is available for the following data sources: Microsoft SQL, Oracle, MySQL, PostgreSQL, SQLite and MariaDB.

▪    In the Data section, choose the Single Queries option and click on Add Query (Assistant).

▪    Choose the table and the fields that will be passed to the query. This is equivalent to defining the SELECT <Fields> FROM <Table> section of the SQL query.

▪    By clicking on the green plus sign, a context menu appears where you can choose whether to add a condition (WHERE) or create a new group.

▪    Click on a condition to edit/change it.

▪    Remove a condition by clicking on the X symbol.

▪    By clicking on an operator, you can move the group up or down, move it into a new group or integrate it into a parent group.

Click on "Convert to SQL Query" to convert the query created in the assistant to a regular SQL query. This allows you to process the query directly using SQL instead of the assistant. The assistant is no longer available for this query after the conversion!

Add (WHERE) condition

You can define any number of conditions and thereby access all of the displayed fields.

▪    To define a condition, click on the green plus symbol in the Query Assistant and then "Add Condition".

Figure 2.19: Define condition or group

▪    In the "Fields" list, click on the field that contains the desired property.

The symbols show the respective field types (alphanumeric, numeric, date, logical).

Figure 2.20: Define condition

▪    Select the desired operator from the "Operators" list. Operators that are permissible for the field selected will be displayed (e.g. equal to, not equal to, begins with, contains, is empty).

▪    Enter or select the property (Fixed value) to be searched for in the "Comparative value" box or compare the property with another field in the same table (Field).

▪    Example for fixed value: Status = "won"

▪    Example for field: Start date greater than planned date.

▪    For date (time) fields, the following additional functions are available: Year(), Quarter(), Month(), Day(), Hour(), Minute(), Second(). Select one of the functions and enter a comparative value.

Example: All orders from year "2016".

▪    If desired, specify "Case sensitive" for the input fields

Note:  The "Case sensitive" option can only be executed when this has been configured in the database server.

▪    To return to the Filter Assistant, select "OK".

▪    To add an additional condition, click on the green plus sign. You now have the following options:

▪    Add condition

▪    Create new group

▪    Click on "Test Query" to check the query.

Creating Groups

Multiple conditions are combined into a group and groups can also contain additional groups. They can be created in various manners and any number of hierarchies are supported:

▪    To create a new group, click on the green plus sign and select "Create new group" from the context menu.

▪    By clicking on an operator (e.g., "all"), you can move the group up or down, move it into a new group or integrate it into a parent group.

Figure 2.21: Link or edit conditions

By default, for each group, the operator is set to "all". To change the operator, click on it and choose one of the logical operators:

▪    All (AND): All conditions must match

▪    Any (OR): Any of the conditions must match

▪    Not any (NOT AND, NAND): One of the conditions must not match

Example: All except (Country = "DE" and Category="Newsletter")

Number of matches: All except "DE" and all "DE" without "Newsletter"

▪    None (NOT OR, NOR): None of the conditions may match.

Example: All except (Country = "DE" NOR Country = "CH" NOR Country "AT")

Number of matches: All except "DE", "CH", "AT"