Queries are the actual providers of tabular data. They use specific data source drivers.
Queries have unique names associated with them. This allows using multiple queries that have identical field (or column) names. See Section 3.4.2
An SQL query uses an SQL data source. An SQL query provides tabular data in rows and columns. The columns have names. One row of data is made up from individual values in columns.
Examples:
SELECT * FROM table1;
SELECT column1, column2 FROM table1;
For more information, read the specific database server documentation you intend to use.
File queries specify the file name and path on the computer. OpenCReports then loads the file into memory and processes it to present data on the report.
Data queries pass the internal data. OpenCReports processes it to present data on the report.
Reports may use one or more queries. If a report uses more queries, one of them must be the report's primary query.
Supplementary queries are either followers of the primary query, or independent queries
Supplementary queries may be associated with the primary query as so called follower queries. Any query may be a follower to the primary query.
There are two kinds of follower queries:
regular, or basic follower queries, and
so called N:1 (N-to-one) followers
A follower query is run along the primary query and their rows are laid out side by side. The first row of the follower query is assigned the first row of the primary query. The second row of the follower query is assigned to the second row of the primary query, and so on. The number of rows of the complete data set is determined by the primary query. If the follower query runs out of rows before the primary, the columns values will be presented as empty data, i.e. SQL NULLs.
This is similar to using LEFT OUTER JOIN
and using ROWNUM in Oracle or
the row_number() SQL function
in PostgreSQL as the matching value between the
primary query and the follower query.
An N:1 follower query, for all intents and
purposes, is the right side query in a
LEFT OUTER JOIN query, with
the primary query on the left side. Rows of the
main query and the follower query are matched
according to a specified boolean expression.
One of the use cases of follower queries is to use data from different datasources. Nowadays, with foreign queries standardized in SQL and more database servers implementing it in a performant manner, its use case is more limited. Still, using data from different file based datasources, or using from an SQL database server and from a file based datasource at the same time is possible with OpenCReports.
Multiple queries may be declared for a report. If a query is neither set as a follower for a previously declared query, nor set as the report's main query, then it is an independent query.
Independent queries will stay on their first row during the report run, so they can be considered constant.
Therefore, column references of independent queries may be used in expressions that would need a constant value.