Fetching report data from a database using SQL

You can use SQL statements to retrieve the data for the report from database tables, requiring a connection to the database and the use of an SQL cursor.

The SimpleReport.4gl program uses this technique, shown in the runReportFromDatabase function.

Tip: Where possible, use a single data set, gathering multiple database tables into this data set. The database can then use a single SELECT statement, which allows for better performance than running multiple queries. However, multiple data sets are necessary in some cases; for example, you need multiple independent lists of data in your reports, or your query is too complex for the database engine.