Documente Academic
Documente Profesional
Documente Cultură
Visit the www.windev.com site on a regular basis (Download section) to find out whether upgrades are available.
This documentation is not contractually binding. Modifications may have been made to the software since this
guide was published. See the online help.
All product names or other trademarks mentioned in this publication are registered trademarks of their respective owners.
PC SOFT 2015: This publication may not be reproduced in part or in full without the express consent of PC SOFT.
TABLE OF CONTENTS
PART 1 - REPORT EDITOR
1. INTRODUCTION
13
25
43
53
5. REPORT BLOCKS
62
6. CONTROLS OF A REPORT
70
93
8. EDITABLE REPORTS
102
9. COMPOSITE REPORTS
105
107
108
112
132
134
137
159
168
3. DESCRIPTION OF A QUERY
188
208
5. ADVANCED QUERY
215
231
236
239
PART 1
Report editor
10
11
12
1. INTRODUCTION
1.1 What is a report?
A report provides a custom view of the data: data entered in the database, data found in a text file, ...
Depending on the product used, the data found in the report can be displayed in different formats:
In WinDev:
In a Windows application, a report can be displayed on the screen, saved in a file (HTML, PDF, PCL),
printed on a printer, ...
In a Linux application, a report can be saved in a PDF file.
In WebDev, a report can be saved in an HTML or PDF file, sent by email, displayed in the browser of the
Web user or printed on a printer connected to the server,
In WinDev Mobile:
In a WinDev Mobile application, a report can be printed on a printer (in PCL format) or saved in a PCL
file.
In an iOS application, a report can be saved in a PDF file.
A report includes:
blocks dividing the report into different sections (see Report blocks, page 62, for more details).
controls where the report data is displayed (see Controls of a report, page 70, for more details).
A report can be used to summarize and synthesize the data. You have the ability to:
group the data,
sort the data according to any criterion,
perform calculations (means, statistics) or even create charts,
display the data in several columns.
Just think of a report and the report editor will create it.
13
Order form
(print preview in WinDev)
Details form
of a supplier
14
In WebDev:
15
In WinDev Mobile:
The report editor can also be used to create customizable blank reports.
The method for creating a report is straightforward. A wizard helps you create the report. At the end of the
description, the report corresponding to your choices is generated. The report can be run:
from the editor directly,
from a site or from an application.
You can modify the layout of the report, add, modify or delete controls. You also have the ability to perform
specific processes in WLanguage (the programming language of WinDev, WebDev and WinDev Mobile).
The report editor is easy to use. It proposes several features:
Choosing the destination of the report execution:
You have the ability to print in a file in PDF, HTML, XML, XLS, RTF or PCL format.
In WebDev, this file is saved in a directory accessible in write mode on the server. Then, this file can be
displayed on the browser.
In WinDev, the report can be previewed and printed from the print preview.
16
17
1.2.2 Differences between the standard report editor and Reports & Queries
Two versions of the report editor are available:
the standard report editor.
This version is supplied with WinDev, WebDev and WinDev Mobile. It can only be used when developing a WinDev/WinDev Mobile application or a WebDev site.
the user version of the report editor (also called Reports & Queries). This editor is supplied with WinDev only.
This version is independent of WinDev and it can be used by the end users.
Some features of the report editor are not available in this version.
The icon
indicates the differences between the user version of the report editor and the standard report editor.
Standard report editor
The standard report editor enables you to create reports from the editor and to run them from the editor or
from an application developed in WinDev, WinDev Mobile or WebDev.
The dongle of the product used is required to use the report editor. It must be plugged into the parallel port or
into the USB port of your computer when using the editor.
However, no dongle is required for the end users to run a report from a WinDev, WinDev Mobile or WebDev
application.
Several examples are supplied with the standard report editor. These examples describe the main reports
that can be used in your applications (invoice, list, labels, ).
To find out the list of examples for using reports:
1. Display the guide (on the "Home" pane, in the "Online help" group, expand "Help" and select "See the
guide").
2. Enter the "Report" keyword and click "Go". The list of examples for using reports is displayed.
Check these examples, they will teach you a lot and you will be able to use them when you create your own
reports!
User version of the report editor (Reports & Queries - WinDev only)
Reports& Queries enables you to create and run reports directly from the editor (WinDev is not required).
The reports cannot contain code lines for modifying the data files (functions used to perform write operations
in the files for instance).
The created reports can be run from the report editor or from a WinDev application (if the application supports the reports created in Reports & Queries).
No dongle is required to use Reports & Queries.
Some operations are required to create new queries or to modify existing queries with Reports & Queries. See
Distributing Reports & Queries, page 231 for more details.
Documentation
Reports & Queries and the standard report editor are supplied with the same online help. The standard
report editor is also supplied with printed documentation.
Printed documentation
The printed documentation (the guide you are reading) is designed to help you discover and use the report
editor. The second part of this guide describes the query editor.
The "Report Editor Guide" is supplied with the "WLanguage" guide, the "Tutorial" and the "Concepts" guide.
18
Online help
The online help is intended to help you handle the editor. The online help is proposed:
as a local help. The required files are installed on the development computer.
as an Internet-based help. This help can be accessed from any computer equipped with an Internet access.
This help is updated on a regular basis.
To access the online help:
on the "Home" pane, in the "Online help" group, expand "Help" and select "Summary" or "Index of the
help".
press the [F1] key from any editor.
To modify the type of online help used:
1. On the "Home" pane, in the "Environment" group, expand "Options" and select "General options of
XXX".
2. In the "Help" tab, select the access mode to the help database: "Use the help database by Internet" or
"Use the local help database" as well as the preferred language.
3. Validate.
Setup
The registration card supplied with your product is very important. It enables you to benefit from the free services offered by PC Soft to its customers: free Technical Support, information about new releases, product
upgrades,
Fill and return your registration card today.
19
Ribbon
Gives quick access to the main features of the report editor. This ribbon includes panes, groups and options.
See A menu shaped like a ribbon, page 22 for more details.
Alignment rulers
Used to align the controls in the report. To display the rulers, press [Ctrl]+[R].
Report currently edited
Scrollbars are used to scroll the large reports. You also have the ability to perform a zoom in the report to view
the report elements more precisely ([Ctrl]+mouse wheel).
Vertical panes
Displays:
the elements (files, variables, items, reports, controls, ) available in the current project ("Project
explorer" pane).
the description of report elements via the modifier.
20
Important
In Reports & Queries, only the "Project explorer" and "Modifier" panes are available.
Code window
Displays the processes associated with the report, with its blocks and controls.
Description window
Allows you to view and/or modify the characteristics:
of the selected controls.
the current report.
Opened documents
Displays a button for each document opened in the report editor. To display the requested element in the
foreground, all you have to do is click the corresponding "button".
Horizontal panes
Displays:
the compilation errors (errors found in the WLanguage code) or the GUI errors ("Compilation errors"
pane),
the search tool ("Find-Replace" pane),
the debugger when running the test of an element ("Debugger" pane),
21
1.
WinDev/WebDev/WinDev Mobile button (top left). This button is used to display the "About" information for the current product.
2.
3.
4. Quick access buttons. These buttons correspond to the most often used options:
New, Open,
Save,
Go of project,
Go of window or page,
5. Ribbon panes. These panes are used to access the different options.
7.
Group button. Button found at the extremity of a group used to perform a specific action (display
the options of the current element, display the help, ).
8. Ribbon options. Several types of options are available in the ribbon:
Buttons to click
Options to check.
Button with arrow used to expand the options.
2 types of buttons with arrow are available:
- the buttons with arrow used to expand a menu.
- the buttons with arrow used either to expand a menu (click on the arrow),
or to perform a default action (click on the button icon).
22
Shortcut
F4
F12
Shift + F8
Ctrl + F8
F8
Display the full name of the blocks / Display the short name of the blocks
F10
F5
F7
F11
Ctrl + R
Help
F1
Ctrl + Z
Shift + F5
Ctrl + Shift + C
Right/Left arrow
Display the code associated with the selected element in the "Context-sensitive Ctrl + Shift + F2
view of code" pane
Edit the code of the selection
F2
Ctrl + S
Save as
Ctrl + Shift + S
Save all
Alt + S
Ctrl + Shift + W
Ctrl + P
Ctrl + Q
Ctrl + W
Ctrl + G
Ctrl + I
23
Ctrl + N
Ctrl + O
Open a project
Ctrl + Shift + O
Ctrl + U
Del
Alt + F9
Ctrl + F9
F9
Alt + D
Zoom at 100 %
Ctrl + Alt + 0
Zoom + / -
24
To open a project, on the "Home" pane, in the "General" group, expand "Open" and select "Open a project"
(the corresponding shortcut is CTRL SHIFT O).
25
26
Use examples
Form for entering incoming calls
Form for entering the absenteeism
Form for entering the products received
Form report:
Reading the data source of the report
The data read in the data source is displayed in a form: each report page displays the data of several
records.
Use examples
Detailed list.
Data grouped according to a criterion.
27
Label report:
Reading the data source of the report
Each record read in the data source corresponds to a label.
Use examples
Price labels
Address labels
Information specific to the creation of labels
Specific information is required to create labels:
the number of identical copies that will be printed for each label.
the format of labels and/or the format of the label sheet. This format can correspond:
- to a custom format:
1. Select the "<Custom>" element in the "Manufacturer" combo box.
2. Specify the format of the label sheet on which the labels will be printed.
3. Specify the format of labels.
4. Specify the number of labels that will be printed across the page width.
- to a preset format:
1. Select the brand of labels used in the "Manufacturer" combo box.
2. Select the model of labels used in the "Model" combo box.
3. The information specific to the labels used (caption, size of labels and number of labels printed
across the page width) is displayed.
Note: Check "inches" to display the size of the labels in inches.
28
Table report:
Reading the data source of the report
Each table row corresponds to a record read in the data source of the report (data file, query, ).
Simple examples
Summary table
Invoice
Detailed list
Data grouped according to a criterion
See Using tables in a report, page 93 for more details.
Crosstab report:
Reading the data source of the report
The data read in the data source is displayed in a double-entry table.
29
Use example
Table representing the repartition of the turnover per product and per month (or per year).
30
Multicolumn report:
Reading the data source of the report
if the multicolumn report is a Table report, each table row corresponds to a record read in the data
source of the report (data file, query, ).
If the multicolumn report is a Form report, the data read in the data source is displayed as a form: each
page displays the data from one or more records.
Use example
Product catalog.
31
Composite report:
Reading the data source of the report
The composite report includes several sub-reports. Each sub-report can have a specific type. The reading
of the data source of the sub-reports depends on the type of the sub-reports.
Use example
Printing orders and sales agreements,
Printing statistics and summary chart.
Report on Form:
Reading the data source of the report
The data read in the data source is displayed in a form: each page displays the data of one or more
records.
Use examples
Postal forms
Check
Tax form
32
33
Important
Data file: The data to print comes from a data file described in the project analysis. This data file can
have any format (HFSQL Classic, Oracle, ).
The data files and the file items that can be used in the reports created by Reports &
Queries are defined by the developer in the data model editor of WinDev. See Distributing Reports & Queries, page 231 for more details.
Query: The data to print comes from a query. This query corresponds to:
a query created and saved in the query editor.
a query created when creating the report.
Important
Table, Organizer or Scheduler control found in a window or in a page: The data to print comes from a
specific control found in one of the application windows or in one of the site pages. The records are
selected by the control and they are printed by the report.
Reports & Queries cannot be used to create reports on a Table control, an Organizer control or a Scheduler control. However, you have the ability to customize the reports on a
Table, Organizer or Scheduler control created in the standard report editor (color, fonts,
size, linked column, ).
Important
Existing variable: The data to print comes from a WLanguage variable of the project or report. This
variable can be a simple array, a member of classes, a member of structures or a member of advanced variables.
Important
Important
View on a HFSQL Classic data file: The data to print comes from a HFSQL view.
34
Reports & Queries cannot be used to create reports on a HFSQL view. However, you have
the ability to customize the reports on a HFSQL view created in the standard report editor
(color, fonts, size, ).
Important
Programming the reading of the data source: To program and select yourself the records to
display in the report, choose a report based on a programmed data source. See Report on a
programmed data source, page 52 for more details.
Reports & Queries cannot be used to create reports on a programmed data source.
No data source: The report will not be linked to any data source.
These data sources are presented in the Data sources of a report, page 43.
Note: If one of the above-mentioned data sources is selected, the records that will be displayed in the report
are automatically selected by the report editor.
To manually program and select the records that will be displayed in the report, choose a report with programmed reading of the data source.
To make the result of a query easier to read, the records can be sorted according to one or more items. Sorting the records means classifying them in an ascending order or in descending order. For example, the customers can be sorted by name, from A to Z.
If your report is based on a query, the sort order is defined when creating the query. However, you have the
ability to:
add or delete a sort item to/from an existing report.
modify the sort order performed on an item in an existing report.
To improve the sort, you can also use:
WLanguage functions (Left, Right, and so on ).
a WLanguage procedure (server procedure in WebDev). This procedure will be automatically called to
sort the records displayed in the report. This procedure must be a global procedure of the project or a
local procedure of the report. See Sort procedure, page 140 for more details.
See the online help (keyword: "Sort, Report") for more details.
The breaks
The break is used to group the records corresponding to a sort criterion. For example:
to list customers by city, simply sort the customer by city then by name and perform a break on the city.
35
to list the stock price per day, all you have to do is sort the stocks by date and create a break on the date.
Adding a break automatically generates the Break Header and Footer blocks. These blocks are used to:
display the content of the break item (in the Break header block).
perform calculations on the records found in the break (in the Break footer block).
See Report blocks, page 62 for more details.
The report editor proposes two types of breaks:
automatic break (the most common one). The break is performed on an item belonging to the data source
of the report.
programmed break. The break is defined by programming in the "Break?" process of the Break Header
block. See Break process, page 140 for more details.
See the online help (keyword: "Break, Report break") for more details.
36
37
38
2.4.5 WinDev Mobile: Opening a window in test mode in the code of the project
When running the test of a report, a WLanguage error occurs if a window is opened in the initialization code
of the project or in the end code of the project. To avoid this error, InTestMode must be used to configure the
opening of the window. For example:
IF InTestMode() = False THEN Open(WIN_MyWindow)
However, you can use the functions for opening the system information boxes (Info or Trace for example).
Paper printing
Print preview
X (WinDev only)
X
X
X
39
PDF file
Text file
Sending a fax
PCL file
XLS file
* The destinations proposed by the preview can be modified in the "Details" tab of the report description or by
programming with iParameter.
See the online help for more details.
WinDev Mobile: All the options are available when running the test of a report in the editor. However, when
printing a report by programming:
in a Windows Mobile application, the prints can only be performed on a PCL printer or in a PCL file.
in an iOS application, the prints can only be performed in a PDF file.
Note: By default, the print mode of the report is automatically asked when running the test of each report in a
specific window. To avoid displaying this window during the test of the report:
1. Display the edit options of the report editor: on the "Display" pane, click the group button of "Options"
.
2. In the "Printout" tab of the edit options, uncheck "Ask for the printout mode". In this case, the report
whose test is run will be viewed in a print preview.
40
41
Notes:
To preview a report, a printer must be installed on the current computer.
Print preview performed with the WLanguage functions: If you are using the WLanguage function to print,
you can also benefit from the features of the print preview. The toolbar will be displayed and annotations
can be made.
When using the button bar, the print preview is automatically closed once the file is saved.
Important
If the current report can be modified by the end user, the following icons allow him to:
modify the current report,:
create a new report,:
Customizing the preview: Your application uses a skin template? Why not use this skin template for the preview window. WinDev gives you the ability to customize the preview window. See the online help (keyword:
"Customizing, Preview window") for more details.
Previewing a print performed via the WLanguage functions: The features of the print preview are also
available when the print is performed with the WLanguage functions.
Configuring the export options available in the preview:
To only display some export options:
- use iParameterPreview. This function, used in the initialization code of the project, allows you to choose
the export options that will be displayed for all of the applications reports.
- directly configure the buttons displayed for each report in the report description ("GUI" tab).
To configure the report options, use:
- iParameterPDF to configure the print in a PDF file,
- iParameterExport to configure the sending of emails,
- iParameterXLS to configure the print in an XLS file.
Printing from the print preview: To find out whether the print was performed from the preview window, use
iDocumentPrinted.
When using the export option, the print preview window is automatically closed after the document is printed into a file.
42
Important
43
3.2.2 Characteristics
Search key
A report based on a data file uses a search key. This key is used to browse the records that will be printed in
the report. This key is defined in the data file.
Bounded report
A report based on a data file can be bounded on the search key used. For example, a report based on the
"Customer" file can print all the customers or only the customers whose name starts with the letter "C" or "E"
if the report is bounded.
See the online help (keyword: "Bound, Bounds of a report") for more details.
The query must be created with the query editor before the report is created (see How do I create a query?,
page 168, for more details). When creating the report, all you have to do is specify the name of the query
used.
If the query is modified in the query editor (deletion of result items for instance), a synchronization screen is
displayed when the query is closed. Therefore, the modifications performed on the query can be applied to all
the elements of the project that use this query (including reports). See Consistency with the analysis,
page 205 for more details.
44
The query is created when creating the report. This query will be modified from the report editor.
To modify the embedded query, on the "Modification" pane, in the "Report" group, click "Edit the query". The
query is displayed in the query editor.
If modifications are performed in the query, the report editor lists these modifications as well as their incidence on the report.
Note: To switch from the embedded mode to the independent mode (which means to extract a query from a
report):
1. Display the report in the report editor.
2. Select "Edit the query" from the popup menu of the report. The query is displayed in the query editor.
3. On the "Home" pane, in the "General" group, expand "Save" and select "Export .. To an independent
query".
4. Save the new query.
Report on query with parameters
Important
An independent query or an embedded query can accept parameters. In this case, one or several selection
conditions expect a parameter when the query is run. This parameter can correspond to the value of an edit
control found in an application window or in a page site.
For example, to print the invoice for a given customer, all you have to do is create a report based on a query
with parameters. In this query, the parameter will be the name of the customer. Therefore, the value of the
parameter must be specified before the report is printed:
when running the test of the report based on a query with parameters, a window (or a page) allows you to
enter the parameters of the query.
at run time, the parameters of the query must be specified in iInitReportQuery (before using iPrintReport).
If the query is created in Reports & Queries, there is no need to use iInitReportQuery to
specify the query parameters. Indeed, when a report based on a query with parameters is
run from Reports & Queries, a window allows you to enter the parameters of the query.
45
Important
Important
A report on a HFSQL view is used to print records coming from a HFSQL Classic or Client/Server view. This
type of report is kept for backward compatibility.
Note: A HFSQL view corresponds to a "memory image" of all or part of a data file. A view is stored in memory,
which insulates it from the modifications made to the associated data file. Once created (HCreateView), a
view can be handled like any HFSQL data file. See the online help (keyword: "HFSQL view") for more details.
Reports & Queries cannot be used to create reports on a HFSQL view. However, you have
the ability to customize the reports on a HFSQL view created in the standard report editor
(color, fonts, size, ).
When the report on a HFSQL view is created, you have the ability to:
modify the data source of the report ("Data" tab of the report description).
add or delete Item controls linked to the HFSQL view associated with the report.
See Report based on a HFSQL Classic view, page 126 for more details.
3.5.2 Characteristics
Base File
A report based on a HFSQL view is linked to the base file of this HFSQL view. The report is used to print the
records coming from this base file.
Order for printing the records
The order in which the records are printed corresponds to the order of records defined in the HFSQL view
(when the view was created or defined by HSortView).
46
Important
See Report based on a memory zone, page 128 for more details.
Notes :
This type of report is not available in WinDev Mobile.
This type of report is kept for backward compatibility.
3.6.2 Characteristics
Base File
A report based on a memory zone is linked to the base file of this memory zone. The report is used to print
the records coming from this base file.
Order for printing the records
The order for printing the records corresponds to the order of the record numbers defined in the memory
zone.
Important
A report based on a Table control is used to directly print the information displayed in a browsing or memory
Table control found in an application window or in a site page.
Reports & Queries cannot be used to create reports on a Table control.
However, you have the ability to customize the reports on a Table control created in the
standard report editor (color, fonts, size, linked column, ).
47
3.7.2 Characteristics
Correspondence between records
The test of a report based on a table cannot be run from the report editor because the window or the page
containing the table must be opened. Therefore, you must:
program the print of a report based on a table. See Report on a Table control, page 122 for more
details.
run the test of the window/page (or project) used to start the print.
This list:
contains three items: "Name",
"Company" and "City".
contains as many records as customers.
48
Important
A report on an Organizer control is used to directly print the information displayed in an Organizer control
found:
in a window of the application. This window must be displayed when printing the report.
in an internal window. The window displaying the internal window must be displayed.
Reports & Queries cannot be used to create reports on an Organizer control.
However, you have the ability to customize the reports based on an Organizer control
created in the standard report editor (color, fonts, size, linked column, ).
A report based on an Organizer control can be created from the report editor: to do so, select an Organizer
report based on an Organizer control. When creating the report, you have the ability to specify the number of
days to display as well as the display mode of resources (in row or in column).
Once the report on an Organizer control is created, you can:
modify the data source of the report ("Data" tab of the report description).
modify the characteristics of the organizer ("General" tab of the organizer description).
Notes:
Only an Organizer report can be created on an Organizer control.
This type of report is available in WinDev only.
3.8.2 Characteristics
Correspondence
All the rows and columns found in the Organizer control are displayed in the Organizer report.
Running the test of a report based an Organizer control
The test of a report based on an Organizer control cannot be run from the report editor because the window
containing the Organizer control must be opened. To run the test of a report on an Organizer control, you
must:
Create (if necessary) a button in the window containing the Organizer control. This button is used to print
the report on the Organizer control (iPrintReport).
Case of internal windows: If the Organizer control is found in an internal window, the button should be created in the internal window (and not in the host window).
Run the test of the window containing the Organizer control then run the report test (via the button).
Case of internal windows: the test must be run from the window that hosts the internal window.
49
Important
A report on a Scheduler control is used to directly print the information displayed in a Scheduler control
found:
in a window of the application. This window must be displayed when printing the report.
in an internal window. The window displaying the internal window must be displayed.
A report based on a Scheduler control can be created from the report editor: to do so, select a Scheduler
report based on a Scheduler control. When creating the report, you have the ability to specify the number of
days to display as well as the display mode of resources (in row or in column).
Reports & Queries cannot be used to create reports on an Organizer control.
However, you have the ability to customize the reports based on an Organizer control
created in the standard report editor (color, fonts, size, linked column, ).
3.9.2 Characteristics
Correspondence
Each row and each column found in the Scheduler control are displayed in the Scheduler report.
Running the test of a report based on a Scheduler control
The test of a report on a Scheduler control cannot be run from the report editor because the window containing the Scheduler control must be opened. To run the test of a report on a Scheduler control, you must:
Create (if necessary) a button in the window of the Scheduler control. This button is used to print the report
on the Scheduler control (iPrintReport).
Case of internal windows: If the Scheduler control is found in an internal window, the button should be created in the internal window (and not in the host window).
Run the test of the window containing the Scheduler control then run the report test (via the button).
Case of internal windows: the test must be run from the window that hosts the internal window.
50
3.10.2 Characteristics
Correspondence between records
Each line found in the text file must correspond to a record. Each line contains various information, called
items. The items are separated by a separator.
51
Important
In a report based on a programmed data source, the reading of the records that will be displayed in the report
requires full programming in WLanguage. The data source can have any type (HFSQL data file, query, text file,
data file from an external database, ).
Reports & Queries cannot be used to create reports on a programmed data source.
See the online help (keyword: "Data source of a report, Programmed data source") for more details.
When the report based on a programmed data source is created, you can:
modify the data source of the report ("Data" tab of the report description).
add or delete Item controls linked to the data source of the report.
52
53
4.2.4 Options
The "Options" tab in the description window of the report is as follows:
54
specify whether the first page is a cover page. In this case, the first page will be displayed on the right in the
preview (in side-by-side display mode).
specify the operating mode of the report if the page format is not supported by the printer.
specify the style of the table if the report contains a table (see Using tables in a report, page 93 for more
details).
specify the style of labels if the report is a label report.
specify the list of templates used by the report.
4.2.6 Language
A report can be multilingual: this report can be displayed and printed in several languages.
The "Language" tab found in the project description is used to configure:
the languages supported by the current report.
the language displayed in the report editor: this language will be used by default when the report is displayed in the editor.
The following information can be entered in several languages:
all the messages displayed while the report is printed. These messages are translated in the different
description windows.
the caption of static controls or RTF controls: to translate these captions, all you have to do is modify
the language displayed in the report and enter the translations in the report in edit. This operation is
performed on the "Display" pane, in the "Options" group, by expanding "Language displayed".
the input mask of item controls, calculated controls or preset controls.
the image files used in the report.
the form of the report.
55
56
At run time, you can specify whether the image of the form must be printed or not. The image of the form is
not printed by default.
For example:
57
58
59
The mouse or the keyboard can be used to optimize the view of the report.
Moves with the mouse
Rotation (left mouse button)
Click the report view and move the mouse while keeping the left
button down.
Click the report view and move the mouse while keeping the
right button down.
Use the arrow keys as well as the + and - keys on the numeric
keypad.
You can also use the numbers on the numeric keypad.
Relocation
Keep the SHIFT key down and use the arrow keys on the numeric
keypad.
Zoom
60
Important
Note: You also have the ability to create your own skin templates. See the online help (keyword: "Skin template, Creating a skin template for a report") for more details.
Important
When describing a report, a template can be applied to this report. A report template is used to define the
characteristics common to a set of reports (presence of different controls, specific code to run, ). A report
template can be applied to one or more reports. The characteristics of the template can be overloaded by the
report that uses the template.
To change a template or apply a template to a report:
1. On the "Modification" pane, in the "Templates and skin template" group, expand "Templates" and
select "List of templates used".
2. In the window that is displayed, select the requested template.
Note: See the online help (keyword: "Template, report template") for more details.
61
5. REPORT BLOCKS
5.1 Overview
A printed report created by the report editor includes several sections:
a start of document
a page header
a body
a page footer
an end of document
one or more breaks, if the report is sorted
62
To manage the different sections of the report, the report editor divides the structure of a report into blocks.
A WLanguage process can be associated with each block.
Report in edit
Previewing
the execution of
the report
63
Note: The Break header block and the Break footer block cannot be dissociated. However, one of these
blocks can be made invisible if necessary (in the description window of the block or via ..Visible).
65
Note: The characteristics of a block can also be viewed in the "Modifier" pane:
1. On the "Home" pane, in the "Environment" group, expand "Panes".
2. Select "Modifier".
3. Click the caption of the block to view its description in the modifier.
66
Keep space for the page footer when it is invisible (for Page Footer blocks only):
By default, the space taken by the Page Footer block will always be kept in the report pages (regardless
of whether the block is visible or not). With this option, the space taken by the Page Footer block will be
kept only in the pages where this block is visible. This option is used to optimize the method for filling
the report pages.
67
Runtime condition
Initialization
Run when initializing the block. The order in which the processes are run when printing a report (including during a test) is as follows:
"Report opening" process.
"Initialization" process of report blocks.
"Initialization" process of controls.
This process is used to:
initialize the "Calculated" controls.
initialize the global variables declared in the "Start of print" process of the
report.
perform block substitutions.
Before printing
After printing
Break ?
Reminder: If the print destination is an HTML file, the Page Header and Page Footer blocks are only printed
once .
68
Effect
Anchor
AnchorRateHeight
Used to find out and modify the anchor rate in height of a block.
Border
BrushColor
Height
Image
InitialHeight
Name
Plane
Used to find out and modify the plane associated with the block.
Process
Used to modify the processes that must be run by the events on a control.
State
Visible
Used to find out whether a block is visible and to make a block visible/invisible.
Width
69
6. CONTROLS OF A REPORT
6.1 The different types of controls
Several types of controls are available in the report editor:
Static control
Item
Calculated control
Image
Bar code
RTF Control
Preset control
Graph
Shape
Check Box
Internal report
URL link
Edit control
HTML control
Lets now give a short description of these types of controls, as well as their characteristics and the operations that can be performed on these controls. See the online help (keyword: "Report control (types of controls)") for more details.
70
Examples:
Caption of a control
Caption of table columns
Method 2:
1. Select the control.
2. Display the description window of the control ("Description" from the popup menu).
3. Enter the new caption in each language supported by the control.
4. Modify (if necessary) the formatting of the caption in the "Style" tab ("Text" element).
Multilingual captions
If your application or your site is a multilingual application or site, a different caption can be selected for each
language supported by the report.
The corresponding caption will be printed according to the runtime language of the project.
See Multilingual feature in a report controls, page 81 for more details.
71
72
Examples:
Sum of table
73
2. To link the control to an item or a variable that belongs to the data source of the report, select this item
directly from the "Linked item" list.
3. To link the control to an item that does not belong to the data source of the report, select the "Multifile" option then select the item linked to the current control.
Multilingual images
If your application or your site is multilingual, a different image can be selected for each language supported
by the report. This option is useful when the images contain a text for example.
The corresponding image will be printed according to the runtime language of the project.
See Multilingual feature in a report controls, page 81 for more details.
74
75
Example:
Date of the day when the report is printed
76
the source (programming, data file, query, WLanguage array, reports data source)
the data displayed by the series.
For each series, you have the ability to define the thickness of the line, the color and type of the points.
Note: if the data source corresponds to the data source of the report, you have the ability to define:
the fill block,
the control or the item corresponding to the series,
the selection mode of data.
Example:
77
Example:
See the online help (keyword: "Internal report") for more details.
Note: Several methods can be used to print several reports simultanesoulsy: nested reports, composite
reports, sequence of reports, ... The internal reports are very easy to use and they allow you to print several
reports side by side without programming.
The "URL Link" control is enabled only if the report is printed in an HTML file or displayed in the preview window. Otherwise, the "URL Link" control is visible but disabled.
78
Example:
To define the item or the variable linked to the "URL Link" control:
1. Display the "Link" tab in the description window of the control ("Description" from the popup menu).
2. To link the control to an item or a variable that belongs to the data source of the report, select this item
or variable directly in the "Linked item" list box.
3. To link the control to an item that does not belong to the data source of the report, select the "Multifile" option then select the item linked to the current control.
Note: The URL links can be easily identified at runtime by .
79
the modifier
The report editor also allows you to:
modify the caption of a control,
modify the name of a control.
80
Characteristics
General
Used to specify the name of the control and the display characteristics of the control. For
example:
the caption of the control (this caption can be multilingual).
the type of information displayed in the control (text, numeric, ).
the display mask used for the control (the mask can be multilingual). See the online
help for more details (keyword: "Mask, Multilingual mask").
the image displayed in an image control, the type of bar code used in a bar code control, the type of chart used in a chart control, etc. See the online help about this control for more details.
GUI
Used to define:
the print parameters of the control (visible, breakable, ).
the size of the control.
the position of the control in the report and in the block to which the control belongs.
Link
Used to define the item or the variable found in the data source to which the control is linked.
The value of this item or variable will be displayed in the control.
Style
Used to define:
the style of the control (background color, border, ).
the font used in the control.
Note: The font used in the control can also be defined via the icons found in the
"Popup" toolbar.
81
The name of the selected control is displayed in the status bar. It can be modified directly.
82
Notes:
To add/delete a control to/from an existing selection, keep the [Ctrl] key down and click the control
that must be added/deleted to/from the selection.
When displaying the 7-tab window ("Description" from the popup menu of the selection), only the
options common to the selected controls will be displayed.
Method 2: with the lasso.
The lasso of the mouse corresponds to a selection area. This area is represented by a dotted rectangle.
1. Click beside the first control to select and keep the left mouse button down.
2. Move the mouse cursor to select all the controls: the selection area is represented by a dotted rectangle (the lasso of the mouse).
3. Release the mouse button when the selection is performed.
Notes:
By default, all the controls with a section included in the lasso area will be selected. To only select the
controls that are entirely included in the lasso area, keep the [Shift] key down during the selection
steps.
To add/delete a control to/from an existing selection, keep the [Ctrl] key down and click the control
that must be added/deleted to/from the selection.
When displaying the 7-tab window ("Description" from the popup menu of the selection), only the
options common to the selected controls will be displayed.
See the online help (keyword: "Select, A control") for more details.
83
84
An "off-report" control allows you, for example, to store a report control without printing it. This allows you to
use the content of the control in programming (like a variable).
To create an "off-report" control:
1. On the "Creation" pane, click the type of control to create.
2. Click the left section of the home window where the control must be created.
85
2. On the "Modification" pane, in the "Alignment" group, expand "Align" and select the requested alignment.
Notes:
Hovering the different alignment options with the mouse is used to view the result of the hovered
option (without applying this option).
You also have the ability choose the requested alignment on the "Alignment" pane.
6.6.3 Zoom
To align your controls perfectly, perform a zoom in your report.
To specify a precise zoom factor, you can:
on the "Display" pane, in the "Help for edit" group, select the zoom factor,
enter the zoom factor in the status bar directly.
To perform a zoom:
1. Press the [Ctrl] key.
2. Modify the zoom factor with the mouse wheel while keeping the [Ctrl] key down.
86
Guides
Note: To view a report with or without guides, select "Guide visible" from the popup menu of the rulers.
Whether they are visible or not, the guides are always enabled: any control moved toward a marker is automatically snapped by it.
The markers can be easily handled with the mouse in the report editor. When a marker is hovered by the
mouse, the cursor turns into a double arrow.
To create a marker:
Method 1:
Click one of the rulers found in the report. The marker is created on the nearest mark.
Method 2:
Select "Add a marker" from the popup menu (right mouse click) of the ruler. The marker is created on the
nearest mark.
To move a marker:
1. Click the marker found in the ruler. The cursor turns into a double arrow.
2. Move the cursor to the new marker position.
To delete a marker, select "Delete the marker" from the popup menu (right mouse click) of a marker.
To delete all the markers found on a ruler, select "Delete all" from the popup menu of a ruler.
87
88
Processes
Runtime condition
Initialization
Run when initializing the report. The order in which the processes are run
when printing a report (including during a test) is as follows:
"Opening" process of the report.
"Initialization" process of report blocks.
"Initialization" process of controls.
Before printing
Click
Run during a mouse click on the control (in the preview window only). A star
allows the user to easily identify the clickable controls
Entry in
Run when the input cursor enters in the control. This process is available for
the edit controls used in preview mode only.
Modification of
Run whenever the content of the control is modified (typing or erasing a character for example). This process is available for the edit controls used in preview mode only.
Exit from
Run when changing control (TAB key, change of control with the mouse, ).
This process is available for the edit controls used in preview mode only.
Source code in WLanguage can be entered in these processes. See Sequence of processes associated with
a report, page 137 for more details.
To view and/or modify the processes of a control, you can:
select the control and press the [F2] key,
select "Code" from the popup menu of the control (right mouse click on the control),
select the control then, on the "Home" pane, in the "General" group, expand
and select "Code of
the selection",
click the "Code" icon in the control description.
89
90
Effect
Anchor
Border
Used to find out and modify the characteristics of the border for a report control.
BrushColor
Caption
CaptionPeriodHeader
Used to find out and modify the content of the caption for the period displayed in
the header of a Scheduler or Organizer control found in a report.
CollapsedImage
Used to find out and/or modify the image of a collapsed row in a TreeView Table
control found in a report.
Color
DisplayCurrency
Allows you to find out and modify the currency used when a value is displayed in a
"Currency + Euro" control.
DisplayedItem
Used to find out and modify the item displayed by the report control
Empty
Used to find out whether the value of the item linked to a control (for the record currently printed) is filled or not
EndDatePeriodDisplayed
Used to find out the end date of the period currently printed in a Scheduler or Organizer control found in a report.
ExpandedImage
Used to find out and/or modify the image of an expanded row in a TreeView Table
control found in a report,
Font
Allows you to find out and modify the characteristics of the font used in a control
FontAppointmentTitle
Allows you to find out and modify the characteristics of the font used for the
title of appointments in the Scheduler and Organizer reports.
FontBold
Used to find out and modify the "Bold" attribute for the content of a control
FontCharset
Allows you to find out and modify the character set used by the font of a control
FontCondensed
Used to find out whether the characters of the text displayed in a control are condensed and to condense (or not) the characters of the text
FontExtended
Used to find out whether the characters of the text displayed in a control are extended and to extend (or not) the characters of the text
FontItalic
Used to find out and modify the "Italic" attribute for the content of a control
FontLarge
Used to find out whether the characters of the text displayed in a control are enlarged and to enlarge (or not) the characters of the text
FontName
Allows you to find out and modify the font used in a control
FontSize
Allows you to find out and modify the size of the font used in a control
FontStrikeOut
Used to find out and modify the "Strikeout" attribute for the content of a control
FontUnderlined
Used to find out and modify the "Underline" attribute for the content of a control
FutureHeight
GranularityGridlines
Allows you to find out and modify the size of the grid used to display the gridlines in
a Scheduler or Organizer control found in a report.
Group
Used to find out whether the control belongs (or not) to a group of controls
Height
Used to find out and modify the height of a control (in centimeters)
HeightInPixel
Used to find out and modify the height of a control (in pixels)
HierarchicalDepth
Used to:
- Find out the depth of a TreeView Item control found in a report,
- Modify the depth of a TreeView Item control found in a report (only if the
report is using a data source by programming).
HorizontalAlignment
Used to find out and modify the horizontal alignment of the Static controls, Calculated controls, Preset controls and Item controls.
Image
InitialHeight
Used to find out the initial height of a control (when opening the report)
InitialWidth
Used to find out the initial width of a control (when opening the report)
InputMask
InternalReportName
Used to find out and specify the name of the report printed in an "Internal report"
control
MemoryCurrency
Allows you to find out and modify the currency used when handling a "Currency +
Euro" control
Multiline
Used to find out whether a control is multiline and to modify this option
Name
Plane
Used to:
- Find out the active plane of a report or the plane to which a control belongs,
- Modify the active plane of a report or associate a control with another plane.
Process
Used to modify the processes that must be run by the events available on a control,
a window, a page, a report,
RightToLeft
Allows you to find out the writing direction actually used in a control.
Size
Used to find out and modify the maximum number of characters found in a control
StartDatePeriodDisplayed
Used to find out the start date of the period currently printed in a Scheduler or
Organizer control found in a report.
State
TextDirection
Allows you to find out and modify the writing direction used in a control (useful for
managing languages such as Arabic or Hebrew).
Title
URL
Used to find out and modify the address associated with a URL control
Value
VerticalAlignment
Used to find out and modify the vertical alignment of the Static controls, Calculated
controls, Preset controls and Item controls.
Visible
Used to find out whether a control is visible and to make a control visible/invisible
Width
Used to find out and modify the width of a control (in centimeters)
WidthInPixel
Used to find out and modify the width of a control (in pixels)
XInitial
Used to find out the initial X coordinate of a control (when opening the report)
91
YInitial
Used to find out the initial Y coordinate of a control (when opening the report)
ZOrder
92
93
List of products
(simple table)
94
95
96
97
98
99
To resize a cell:
1. Select the corresponding cell in the editor. Black handles are displayed.
2. Hover the black handle corresponding to the side to resize. When the mouse cursor turns into a double
arrow, keep the left mouse button down and resize the cell.
3. Release the left mouse button. The resize operation is performed.
100
101
8. EDITABLE REPORTS
8.1 Overview
The report editor allows you to create reports that include edit controls. These reports can be generated in
PDF format.
This enables you to distribute reports, in PDF format if necessary, that allow direct user input in the specified
areas: administrative forms (tax return, postal forms, ).
The data can be printed or stored in a database (when the input is performed from the print preview). Then,
the report becomes an entry form.
The edit controls can be used on all types of reports. In most cases, the edit controls are used on Form
reports, using a PDF in report background for example (see page 56).
102
Runtime condition
Initialization
Before printing
Entry
Exit
Whenever modified
Run whenever the content of the control is modified (typing or erasing a character for example).
103
104
9. COMPOSITE REPORTS
9.1 Overview
The report editor gives you the ability to create "Composite" reports. In this case, the report includes several
sub-reports. Each sub-report can display a different set of data and use a specific orientation. Each subreport is printed one after the other.
Note: The report editor proposes several methods for printing several reports in a single document:
the internal reports, that are used to print several reports side by side. See Internal Report control,
page 78 for more details.
The sequencing of reports that can be performed by programming. This method can be easily implemented. See Sequencing the reports, page 107 for more details.
the nested reports, that are used to create sequencing of complex reports, with support for page footers.
See Nested reports, page 108 for more details.
105
106
Notes :
The pages of the reports found in the sequence are numbered sequentially. The numbering can be modified by iPageNum.
The reports found in the sequence can have different orientations (portrait and/or landscape).
107
If the nested reports have different orientations, iParameter must be called in order to change the orientation of the print accordingly.
4. Configuring the print of page headers and footers for the nested report (iNestedHeaderFooter). This
function can be used:
in the opening code of the main report: it will apply to all the nested reports that will be printed from
the main report.
before printing the nested report: it will only apply to the next nested report.
5. Printing the main report. See Printing a nested report, page 110 for more details.
Note: To print reports with different orientations (portait/landscape), we recommend that you use the
sequencing of reports. This method can be easily implemented. See Sequencing the reports, page 107 for
more details.
11.2.2 Example
The operations required to create nested reports are presented in the following example:
The "RPT_OrderReport" report is based on the "Orders" file. This report is used to print the
characteristics of each order (date, customer number, total amount, ). A break on the
"OrderNum" item is used to separate the different orders.
The "QRY_ProductOrdered" query selects all the products of a specified order. This query
expects an order number in parameter.
The "RPT_ProductOrdered" report is based on the "QRY_ProductOrdered" query. This report
prints the products selected by the "QRY_ProductOrdered" query.
The "RPT_ProductOrdered" report corresponds to the secondary report. This report will be
printed after each break.
1. Create the "RPT_OrderReport" report. This report corresponds to the main report.
2. Create the "QRY_ProductOrdered" query. See How do I create a query?, page 168 for more details.
3. Create the "RPT_ProductOrdered" report. This report corresponds to the secondary report.
Note: The Page footer block of this report will not be printed. See Blocks in the secondary report,
page 110 for more details.
4. Enter the following code in the "After printing" process of the Break footer block of the "RPT_Orders"
report:
// Initialize the query and pass in parameter
// the number of the order currently printed
iInitReportQuery(RPT_ProductOrdered, MySource.OrderNum)
// Print the nested report
iPrintReport(RPT_ProductOrdered)
109
110
Example:
The "RPT_OrderReport" report includes a main report and a secondary report.
The "RPT_OrderReport" report is printed during a click on the "Print" button.
In this example, the click code of the "Print" button is as follows:
WinDev code:
// Open the preview window
iPreview()
// Print the RPT_OrderReport report
iPrintReport(RPT_OrderReport)
WebDev code:
// Configures the destination of the print
iDestination(iHTML, fWebDir() + "\Report.htm")
iPrintReport(RPT_OrderReport)
// Sends the file to the browser
FileDisplay(fWebDir() + "\Report.htm")
111
Important
12.1 Overview
The creation of a report (page 26) and the test of this report (page 37) have been presented in the previous
chapters. You also have the ability to include this report in your applications or in your sites. The user or the
Web user will have the ability to print the report from a button, a menu option, ... for example.
For a WebDev site, the server will prepare the report in the selected format (PDF, HTML, ). Then, you will
have the ability to:
display this report on the browser of the Web user,
save it on the server and propose to download it or to display it,
In an Intranet site, the report can also be printed on a local printer or on a network printer connected to the
server.
112
Caution: If the print destination is a file in HTML, PDF, XML or RTF format, the following points must be checked:
You have the rights to write into the directory in which the document will be generated (the document
is generated in the site directory by default).
If you generate a report in PDF format, this file can be saved in the data directory (path returned by
fDataDir).
If you generate a report in HTML format, this file must be saved in the _WEB directory of the site (path
returned by fWebDir).
A specific name must be used for each document generated on the server. Otherwise, several simultaneous prints would overwrite the prints already performed.
Use GetIdentifier or TimeSys to give a name to your reports (for example: FileName = "CustomerReport" + TimeSys() + ".HTML").
This principle must be adapted according to the data source used in each report.
The principle for printing a report in iOS is straightfoward: a PDF file is created when printing the report. Then,
all you have to do is open this PDF file in the appropriate software and print it on the printer configured for the
computer used.
1. Specify the print mode of the report (preview, direct print, generation of an HTML page, ) with iPreview or iDestination.
2. Start the print in PDF format with iPrintReport.
This principle must be adapted according to the data source used in each report.
Principle for printing a report in WinDev Mobile
The principle for printing a report in WinDev Mobile is straightfoward: a PCL file is created when printing the
report and this file is sent to the destination printer. The content of the PCL file is specific to the printer used.
The steps for printing a report created in the report editor are as follows:
1. Configuring the print parameters:
Printing on the printer selected by the user.
Printing on a printer selected during the development.
2. Print the report.
This principle must be adapted according to the data source used in each report.
Notes:
The result of the print differs according to the selected printer.
In Windows Pocket 2002, the available memory is not sufficient to print reports.
Case 1: Printing on a printer selected by the user
A specific window allows the user to choose the printer that will be used. The user can add a new printer if no
printer is listed.
To perform this type of print, you must:
1. Use iConfigure or iParameter (without specifying any parameters).
2. Use iPrintReport and specify the name of the report to print.
113
Example:
The "RPT_CustomerReport" report will be printed on the printer selected by the user in the
configuration window. This printer will be automatically used for all the other prints performed by this application.
Corresponding code:
// Select the printer
iConfigure()
// Print the report
iPrintReport(RPT_CustomerReport)
114
Tip: The printers referenced on a Pocket PC are stored in the registry of the Pocket PC. To add a new printer
configuration by programming, all you have to do is modify the registry of the Pocket PC. See the online help
for more details.
115
WebDev example:
The "RPT_CustomerReport" report is based on the "Customer" file. This report is used to
print the characteristics of customers.
The "RPT_CustomerReport" report is displayed in a PDF file during a click on the "Customer" link. Then, the PDF file is displayed in the browser.
In this example, the server click code of the "Customer" link is as follows:
// Generates a unique PDF file name
PDFFile is string = fWebDir() + "\" +
"RPT_CustomerReport_" +
DateSys() + TimeSys() + ".pdf"
// Configures the destination of the print
iDestination(iPDF, PDFFile)
// Prints the RPT_CustomerReport report
iPrintReport(RPT_CustomerReport)
// Sends the file to the browser
FileDisplay(PDFFile, "application/pdf")
// Deletes the file
fDelete(PDFFile)
Note: ..SourceName used in the code of the report allows you to find out and modify the name of the data file
associated with the report.
116
WebDev example:
The "RPT_CustomerReport" report is a bounded report based on the "Customer" file. This
report is used to print the characteristics of the customers whose name starts with the letter "D".
The lower bound corresponds to "D". The upper bound corresponds to "D"+hMaxVal.
The "RPT_CustomerReport" report is printed in an HTML file and it is sent to the browser
during a click on the "CustomerD" button.
In this example, the click code of the "CustomerD" button is as follows:
// Generates a unique file name
PDFFile is string = fWebDir() + "\" +
"RPT_CustomerReport_" + DateSys() + TimeSys() + ".pdf"
// Configures the destination of the print
iDestination(iPDF, PDFFile)
// Prints the RPT_CustomerReport report
iPrintReport(RPT_CustomerReport, "D", "D" + hMaxVal)
// Sends the file to the browser
FileDisplay(PDFFile, "application/pdf")
// Deletes the file
fDelete(PDFFile)
117
In this example:
the click code of the "Print" button is as follows:
// Open the preview window
iPreview()
// Print the report while passing parameters
iPrintReport(RPT_ParamReport, EDT_MailshotText,
EDT_SendDate)
WebDev example:
The "RPT_OrderReport" report is a report with parameters used to print the order of a customer identified by a customer number.
The "RPT_OrderReport" report is displayed in a PDF file. This PDF file is sent to the browser
during a click on the "Order" button.
In this example:
the click code of the "Order" button is as follows:
// Generates a unique file name
PDFFile is string = fWebDir() + "\" +
"Invoice_" + DateSys() + TimeSys() + ".pdf"
// Configures the destination of the print
iDestination(iPDF, PDFFile)
118
119
WebDev example:
The "RPT_ParamReport" report is used to print the invoices of a specific customer for
January 2008.
The lower bound corresponds to "01/01/2008" and the upper bound to "01/31/2008".
This report expects the customer number in parameter.
This report is displayed in a PDF file during a click on the "Print" button.
In this example, the click code of the "Print" button is as follows:
// Generates a unique file name
PDFFile is string = fWebDir() + "\" +
"RPT_ParamReport_" + DateSys() + TimeSys() + ".pdf"
// Configures the destination of the print
iDestination(iPDF, PDFFile)
// Prints the report while passing bounds and parameters
iPrintReport(RPT_ParamReport, "01012008", "31012008", CustNum)
// Sends the file to the browser
FileDisplay(PDFFile, "application/pdf")
120
121
For example: The "RPT_QueryReport" report is based on a query with parameters. The parameters expected
by the query are the name and type of the company. These parameters have been entered in the window for
starting the report print.
WinDev code:
// Open the preview window
iPreview()
// Pass the parameters to the query associated with the
report
iInitReportQuery(RPT_QueryReport, CompanyName, CompanyType)
// Print the list of companies
iPrintReport(RPT_QueryReport)
WebDev code:
// Generates a unique file name
MyFile is string = fWebDir() + "\" +
"RPT_QueryReport_" + DateSys() + TimeSys() + ".htm"
// Configures the destination of the print
iDestination(iHTML, MyFile)
// Passes the parameters to the query associated with the
report
iInitReportQuery(RPT_QueryReport, CompanyName, CompanyType)
// Prints the RPT_QueryReport report
iPrintReport(RPT_QueryReport)
// Extracts the name and extension of the generated file
FileName is string = fExtractPath(MyFile,
fFileName + fExtension)
// Sends the file to the browser
FileDisplay(FileName)
Note: If some of the parameters expected by the query are not specified (value corresponding to NULL for
example), the selection conditions corresponding to these parameters will be ignored.
WebDev example:
The information to print is contained in the Table control named "TABLE_CustomerTable"
found in the "PAGE_Customer" page.
The report to print is named "RPT_CustomerReport" and it is displayed in a PDF file during
a click on the "Print" button.
In this example, the click code of the "Print" button is as follows:
// Generates a unique file name
PDFFile is string = fWebDir()+"\"+
"RPT_CustomerReport_" + DateSys() + TimeSys() + ".pdf"
// Prints the report in a PDF file
iDestination(iPDF, PDFFile)
// Prints the report based on "TABLE_CustomerTable"
iPrintReport(RPT_CustomerReport)
// Displays the report in PDF format
FileDisplay(PDFFile, "application/pdf")
// Deletes the file
fDelete(PDFFile)
123
WebDev example:
The "RPT_gglEventReport" report is a report based on the MyEvents variable of gglEvent
type. This report is used to print the list of events found in a Google calendar.
The "RPT_gglEventReport" report is displayed in a PDF file during a click on the "Event" link.
Then, the PDF file is displayed in the browser.
124
Notes:
..SourceName used in the code of the report allows you to find out and modify the name of the data
file associated with the report.
The variable must have been created and initialized before printing the report.
125
WebDev example:
The "RPT_gglEventReport" report is displayed in a PDF file during a click on the "Print the
organizer events" link. Then, the PDF file is displayed in the browser. This report expects in
parameter the organizer for which the events must be listed.
In this example, the click code of the "Print" button is as follows:
// Generates a unique file name
MyFile is string = fWebDir() + "\" +
"RPT_gglEventReport_" + DateSys() + TimeSys() + ".pdf"
// Prints the report in a PDF file
iDestination(iPDF, MyFile)
// Prints the RPT_gglEventReport report
iPrintReport(RPT_gglEventReport, MyOrganizer)
// Displays the report in PDF format
FileDisplay(MyFile, "application/pdf")
// Deletes the file
fDelete(MyFile)
Notes:
The variable must have been created and initialized before printing the report.
If additional parameters must be passed to the report, these parameters must be specified in iPrintReport. See Report with parameters, page 141 for more details.
..SourceName used in the code of the report allows you to find out and modify the variable associated
with the report.
..ViewName used in the report code allows you to find out and change the HFSQL view associated with
the report.
..SourceName used in the report code allows you to find out and modify the base data file of the
HFSQL view associated with the report.
WinDev example:
The user selects the reference of an order in a list. The "Print" button is used to:
create the HFSQL view named "OrderView" containing the lines of the selected order
(HCreateView).
open the preview window (iPreview).
print the "RPT_ViewReport" report (iPrintReport).
In this example, the click code of the "Print" button is as follows:
// Create the view
IF NOT HCreateView("OrderView", ORDLINE, "*",
"Reference", "", "",
hViewExclusive + hViewBreakable) THEN
Error(HErrorInfo())
ELSE
// Open the preview window
iPreview()
// Print the RPT_ViewReport report
iPrintReport(RPT_ViewReport, "OrderView")
END
127
WebDev example:
The Web user selects the reference of an order in a list. The "Print" button is used to:
create the HFSQL view named "OrderView" containing the lines of the selected order
(HCreateView).
view the "RPT_ViewReport" report in a PDF file (iPrintReport).
In this example, the click code of the "Print" button is as follows:
// Create the view
IF NOT HCreateView("OrderView", ORDLINE, "*", "Reference",
"", "", hViewExclusive + hViewBreakable) THEN
Error(HErrorInfo())
ELSE
// Generates a unique file name
PDFFile is string
PDFFile = fWebDir() + "\" + "RPT_ViewReport_" +
DateSys() + TimeSys() + ".pdf"
// Configures the destination of the print
iDestination(iPDF, PDFFile)
// Prints the RPT_ViewReport report
iPrintReport(RPT_ViewReport, "OrderView")
// Sends the file to the browser
FileDisplay(PDFFile, "application/pdf")
END
128
WinDev example:
The user selects the customers to whom a promotional offer must be sent. The name of
the selected customers is found in the "Recipient" list box control.
When all the customers are selected, the user clicks the "Print" button in order to print the
"RPT_MemZoneReport" report.
During a click on the "Print" button:
the "MemZone" memory zone is created.
the record number of each selected customer is retrieved and added into the
"MemZone" memory zone.
the "RPT_MemZoneReport" report is printed.
the "MemZone" memory zone is destroyed.
In this example, the click code of the "Print" button is as follows:
nSubscript is int
// Create the memory zone
MemCreate("MemZone")
// Browse the Recipient list and
// initialize the memory zone
FOR nSubscript = 1 TO Recipient..Occurrence
// Find the current record
HReadSeek(Customer, Name, Recipient[nSubscript])
IF HFound(Customer)=True THEN
// Add elements into the memory zone
MemAdd("MemZone", "", HRecNum())
END
END
// Open the preview window
iPreview()
// Print the report
iPrintReport(MemZoneReport, "MemZone")
// Destroy the memory zone
MemDeleteAll("MemZone")
WebDev example:
The Web user selects the customer to whom a promotional offer must be sent. The name
of the selected customers is found in the "Recipient" list box control.
When all the customers are selected, the Web user clicks the "Print" button in order to print
the "RPT_MemZoneReport" report.
During a click on the "Print" button:
the "MemZone" memory zone is created.
the record number of each selected customer is retrieved and added into the
"MemZone" memory zone.
the "RPT_MemZoneReport" report is displayed in a PDF file.
the "MemZone" memory zone is destroyed.
129
130
WebDev example:
The "RPT_CustomerReport" report is based on the "Customer.TXT" file. This text file contains the characteristics of the customers. This file is accessible from the server.
The "RPT_CustomerReport" report is displayed in a PDF file during a click on the "Customer" button.
In this example, the click code of the "Customer" button is as follows:
// Generates a unique file name
FichierPDF est une chane = fRepWeb() + "\" +
"RPT_CustomerReport_" +
DateSys() + TimeSys() + ".pdf"
// Prints the report in a PDF file
iDestination(iPDF, PDFFile)
// Prints the RPT_CustomerReport report
iPrintReport(RPT_CustomerReport)
// Displays the report in PDF format
FileDisplay(PDFFile, "application/pdf")
// Deletes the PDF file
fDelete(PDFFile)
Effect
iInitReportQuery
Initializes the query linked to the report (for a query with parameters)
iNestedHeaderFooter
Prints (or not) the page headers and footers of the nested report
iPreview / iDestination
iPrintReport
131
13.2 Creating a duplicate copy from the print preview (WinDev only)
13.2.1 Print available by default
The print preview proposes a button allowing the user to create a duplicate copy of the report currently displayed. When this button is clicked, a file picker allows the user to:
enter the name of the duplicate file that will be created.
specify the certificate that will be used to sign the duplicate. The signature of the duplicate is optional.
By default, the duplicate:
is saved in the directory of the application.
has no password.
is named: Dupli_YYYYMMDD_HHMMSS.dpl.
Note: To modify these parameters, you can use iParameterDuplicate before displaying the print preview window.
132
Example:
// Configure the duplicate of the invoice
iParameterDuplicate(iDplPrintout, "C:\Temp",
"MyDuplicate_%d_%h", "DDDD DD MMMM YYYY", "HH.MM.SS")
// Print the duplicate copy
iPreview()
iPrintReport(RPT_Invoice_Report)
iParameterDuplicate
Configures the automatic creation of the duplicate copy generated during the
next print.
133
134
Example 2: Code used to print a watermark in background of a report created with the print functions:
MyWatermark is Watermark
// Text of the watermark
MyWatermark..Text = "Confidential"
// Print preview
iPreview()
// Implement a watermark in document background
// only
iParameterWatermark(iwatermarkPrinting, MyWatermark)
// Prints several pages with watermark
FOR i = 6 TO 10
iPrint(" Page " + i)
iSkipPage()
END
// The last page is empty and it has no watermark
// Ends the print
iEndPrinting()
135
Example 2: Code used to print a watermark in background of a report created with the print functions:
// Print preview
iPreview()
// Implement a watermark in document background
// only
iParameterWatermark(iWatermarkPrinting, "Confidential")
// Prints several pages with watermark
FOR i=6 TO 10
iPrint(" Page " + i)
iSkipPage()
END
// The last page is empty and it has no watermark
// Ends the print
iEndPrinting()
136
5.
6.
7.
8.
9.
10
11.
137
12.
* The order for printing the Start of document, Page header, Page footer and End of document blocks can be
modified in the "Options" tab of the report description ("Report description" from the popup menu of the
report).
Reminder: If the destination of the printing is an HTML file or an XML file, the Page header and Page footer
blocks are only generated once.
For more details about:
the processes associated with the blocks, see Processes of report blocks, page 68.
the processes associated with the controls, seeProcesses of the report controls, page 88.
the different types of blocks, see The different types of blocks, page 63.
the sort procedures, see Sort procedure, page 140.
138
139
Important: The break code is run only if the corresponding break is a programmed break (not linked to a sort
criterion).
See the online help (keyword: "Break in a report") for more details.
140
6. Create the sort procedure. This procedure must return the sort argument. For example:
PROCEDURE SortVal(Criterion)
// Sort by NAME or by CITY
SWITCH Criterion
CASE "City": RESULT Customer.City
CASE "Name": RESULT Customer.Name
END
<NameParamN> = "<DefaultValueParamN>")
Reminder: Some parameters passed to a procedure can be optional parameters. When declaring
the procedure, the optional parameters must be described in last position (to the right), with a
Part 1: Report editor
141
default value preceded by "=". See the online help (keyword: "Parameters, Parameters or a procedure") for more details.
Use these parameters in the report controls.
3. Modifying (if necessary) the application or the site in order to specify the different parameters.
4. Pass the parameters and print the report.
Example:
The program required to create a report with parameters is illustrated by the following example:
The "RPT_ParamReport" report corresponds to a mailshot sent to the customers. This
report expects in parameter the text of the mailshot entered in the "EDT_MailshotText" edit
control.
1. Create the "RPT_ParamReport" report. This report is a Mailshot report. This report is linked to the "Customer" file of your analysis.
2. Customize this report.
3. Enter the following code in the "Opening" process of the "RPT_ParamReport" report:
// Retrieve the parameter passed to the report and
// pass a default parameter for the report test
PROCEDURE RPT_ParamReport(sText = "Default value")
4. In the Body block of this report, add the "STC_MailshotText" static control used to display the text of
the mailshot.
5. Enter the following code in the "Before printing" process of the "STC_MailshotText" control:
// Retrieve the mailshot text
STC_MailshotText = sText
142
Example:
The "RPT_ParamReport" report corresponds to a mailshot sent to the customers. This
report expects in parameter the text of the mailshot entered in the "EDT_MailshotText" edit
control.
The "RPT_ParamReport" report is printed during a click on the "Print" button.
In this example, the code of "Print" button is as follows:
WinDev code:
// Open the preview window
iPreview()
// Print the report while passing parameters
iPrintReport(RPT_ParamRpt, STC_MailshotText)
WebDev code
// Configures the destination of the print
iDestination(iHTML,"RPT_ParamReport_" +
GetIdentifier() + ".htm")
// Prints the report while passing parameters
iPrintReport(RPT_ParamRpt, STC_MailshotText)
// Sends the file to the browser
FileDisplay("RPT_ParamReport_" +
GetIdentifier() + ".htm")
143
Effect
MyReport
MySource
144
Effect
AllModifiableWithReportsAndQueries
Used to find out whether a report can be modified in Reports & Queries
BottomMargin
BrowsedItem
Allows you to find out and modify the item used to automatically browse a
report based on a data file
HSpace
Used to find out and modify the horizontal spacing between the labels in a
"Label" report
HTML
InterfaceModifiableWithReportsAndQueries
Used to find out whether the interface of a report can be modified in Reports &
Queries
LabelHeight
Used to find out and modify the height of labels in a "Label" report
LabelNumberToStart
Used to find out and modify the number of the label from which the print will
start
LabelWidth
Used to find out and modify the width of labels in a "Label" report
LeftMargin
MaxValue
Used to find out and modify the upper bound for a report based on a data file
(the upper bound corresponds to the maximum value allowed for the search
key of the report source file)
MemZoneName
Used to find out the name of the memory zone associated with a report
MinValue
Used to find out and modify the lower bound for a report based on a data file
(the lower bound corresponds to the minimum value allowed for the search key
of the report source file)
MsgSortSel
Used to find out and modify the message displayed when sorting and selecting
the records found in the report
Name
NbColumn
NbCopy
NbLabel
Used to find out and modify the number of labels printed across the page width
NbLabelCopy
NbPrintedRec
NbRecRead
ODBCConnectionName
Allows you to find out and modify the name of the connection used to handle a
database accessed via an ODBC driver
ODBCDatabaseName
Allows you to find out and modify the name of the database used by the query
run on a database accessed via an ODBC driver
ODBCPassword
Allows you to find out and modify the password associated with the user
allowed to access a database via an ODBC driver
ODBCSQLCode
Used to find out and modify the SQL code of the query run on a database
accessed by an ODBC driver
ODBCUserName
Allows you to find out and modify the password of the user allowed to access a
database via an ODBC driver
PageByPagePrint
PageEndStick
PageNumber
Used to find out and modify the page number of a PDF file displayed in report
background.
Plane
Process
Used to modify the processes associated with the events of the report.
RightMargin
RightToLeft
SelectionOnly
Used to find out and modify the mode for printing the lines selected in a report
on table
SourceName
Used to find out the name of the data source of the report and to change the
data source of the report
State
Used to find out and modify the display status of a block in a report
TextDirection
Allows you to find out and modify the writing direction used in a report.
145
TopMargin
TotalNbRec
ViewName
Used to find out the name of the HFSQL view associated with a report
VSpace
Used to find out and modify the vertical spacing between the labels in a "Label"
report
Important
Functions for accessing a record: All the HFSQL functions of WLanguage that modify the record in memory or
the current record in the base file of the report are not recommended in the processes of the report, block or
controls. Indeed, these functions may modify the browse operation performed in the base file of the report.
These functions are: HAdd, HCreation, HCreationIfNotFound, HLast, HWrite, HReadxxx, HModify, HPrevious,
HSetPosition, HFirst, HCross, HSeek, HBackward, HNext, HDelete, ...
The functions for modifying records (HAdd, HModify, HDelete, ) cannot be used in
Reports & Queries.
146
Effects
iAddBookmark
Adds a bookmark into the print preview or dufing the export in PDF.
iBorder
iChangeSubReportSource
iCloseReport
iColumnEnd
iColumnNum
iConfigure
iConfigureReport
iCreateFont
iDidotFont
Selects the unit that will be used for the height of fonts (created by iCreateFont): DIDOT point or PICA point
iDirImageHTML
Used to select the directory in which the images must be generated during a
print in HTML format.
iDocumentCanceled
Allows you to find out whether the current print was canceled by the user
iDocumentPrinted
Allows you to find out whether the user has requested to print the document
from the print preview
iEndReport
iEscape
iFont
iForceComplement
iInfoPrinter
iInitReportQuery
Initializes the query linked to the report (for a query with parameters)
iInitReportQueryConnection
Initializes the query linked to the report (query based on a specific connection)
iInitSubReport
iLastFile
Returns the full name of the last file generated during the print (PDF, RTF, Text,
) or the list of created duplicate files.
iListNestedReports
iListPrinter
iMargin
iMMToPica
iNestedHeaderFooter
Prints (or not) the page headers and footers of the nested report
iPageEnd
iPageHeight
Calculates the height of the printable page (in millimeters) while taking the top
or bottom margins into account
iPageHeightLeft
Calculates the available height (in millimeters) left on the current page while
taking the top or bottom margins into account
iPageNum
iPageWidth
Calculates the width (in millimeters) of the printable page while taking the left
or right margins into account
iParameter
iParameterDuplicate
Configures the automatic creation of the duplicate copy generated during the
next print.
iParameterExport
147
iParameterPDF
iParameterPreview
iParameterReport
Configures the printer by opening the configuration window. This window is initialized with the parameters specified when developing the report (orientation,
margins, )
iParameterWatermark
iParameterXLS
Defines the options for the XLS file generated during the print.
iPicaToMM
iPreview / iDestination
iPrintBlock
iPrintBodyComplement
Forces a Body Complement block to print by specifying the height of the complement block
iPrintDuplicate
iPrintingNation
Modifies the current language for the next print (programmed print or report
print)
iPrintReport
iReportPrintingStatus
iReset
iResetNbPages
iRoundBorder
iSelectFont
Creates a new print font from the standard window for font selection of Windows
iSkipPage
Forces a page skip: the corresponding code is sent to the printer spooler
iSubstBlock
Substitutes a report block for another one during the report print
iTextHeight
Calculates the height of the font for the text to print (en millimeters)
iTextWidth
Calculates the width (in millimeters) of the text to print according to the specified font
iTransparentMagenta
iWindowCancel
Configures the display of the window used to cancel the current print
iZoneHeight
Calculates the necessary height of a fixed-width area in order for the entire text
to be printed in this area (in millimeters)
148
INDEX
Numerics
3 dimensions
59
A
Add
Cell into a table
Column into a table
99
99
Alignment options
Interface checker
Rulers and markers
Snap-on grid
Zoom
Align controls
Alignment markers
Alignment rulers
Array
Associated properties
Report blocks
Report controls
Reports
Automatic retrieval
85
86
87
88
86
85
87
20, 87
93
Align
69
90
144
55
B
Bar code
Blank (type of report)
Blank report
Block
Associated processes
Associated properties
Body
Body Complement
Break Footer
Break Header
Characteristics
Create a block
Delete a block
Description
End of Document
Iteration
Page Footer
Page footer
74
26
26
62
68
69
64
64
64
64
65
67
67
65
65
65
65
65
Page Header
Parameters
Position
Print options
Programming
Re-arrange
Setting
Start of document
Types of blocks
64
66
67
66
67
67
54
64
63
64
64
44
44
35
140
140
64
64
Body
Body Complement
Bound
Bounded report
Break
Break process
Programmed
Break footer
Break header
C
Calculated
Calculations in a report
Caption
Cell
Add
Height
Resize
Selection
Width
Characteristics
Report blocks
Report controls
Table
Chart
Type of control
Check Box
Check box
Circle
Closing a report
Code window
Column
Add
Delete
Move
Remove
72
36
70
98
99
100
100
99
100
65
80
97
76
77
77
77
55
21
99
101
101
101
Part 1: Report Editor
149
Select
Composite (Report)
Composite report
Control
Align
Associated processes
Associated properties
Bar code
Calculated
Characteristics
Chart
Check box
Copy
Copy the style
Create
Delete
Description
Group of controls
Image
Internal report
Item
Move
Multilingual
Off-report control
Preset control
RTF control
Select
Shape
Static
Types of controls
URL link
Copy
Control
Style of a control
Create
Block
Controls
Report
Report with parameters
Table
Crosstab report
Crosstab report (type of report)
Create
Currency + Euro
Custom mailshot (type of report)
Custom mailshot report
99
105
105
70
85
88
90
74
72
80
76
77
83
84
82
85
80
82
73
78
72
84
81
85
75
74
82
77
70
70
78
83
84
67
82
26
141
95
29, 31, 32
29, 31, 32
96
72
33
33
D
Data file
150
43
115
53
43
46
46
52
44
47
51
45
67
101
85
53
65
80
97
21
72, 73
73
132
E
Embedded query
End of Document
End of print (process)
44
65
139
F
Filter (process)
Form
Include in a report
Type of report
Form (type of report)
Form report
Format of the page
Free (type of report)
Functions of WLanguage
139
55, 56
58
32
27
27
37
26
146
G
Group of controls
Guides
82
87
H
HFSQL view
Print the report
HTML
HTML (Control)
HTML control
HTML file
I
Image
Independent query
Inserting a table
Interface
Interface checker
Internal report
Item
Currency
Dual display
Iteration
K
23
23
144
L
Label (type of report)
Label report
Languages of a report
Line
28
28
55
77
M
Magnetism
Main window of the editor
Memory zone
Print the report
Move
Column (table)
Control
Multilingual feature in report controls
86
20
46
128
101
84
81
N
Nested report
O
Off-report control
Opened documents
Opening a report
Options for printing the blocks
85
21
55
66
P
73
44
96
20, 86
86
78
72
72, 73
72, 73
65
Keyboard (shortcuts)
Keyboard shortcuts
Keywords
Reports
108
75
108
Page Footer
Page footer
Page header
Page header, Page header block
Page number
Pane
Parameter
Report
Report blocks
PDF
PDF file
Position of the blocks
Preset
Print
Duplicate copy
On a form
Report
Report based on a memory zone
Report based on a query
Report based on a table control
Report based on a text file
Report based on HFSQL view
Report with parameters
Print margins
Print preview
Printing
HTML
Paper
PDF
Print Preview
RTF
Text File
XML
Process
Break
End of print
Filter
Reading data
65
65
64
64
75
20
141
66
39
39
67
75
132
55
112
128
120
122
130
126
142
37
39
39
39
39
39
39
39
39
140
139
139
139
151
Start of print
Processes
Report
Report blocks
Report controls
Programming
Report
Report blocks
138
138
68
88
137
67
Q
Query
Embedded query
Independent query
Print the report
Query with parameters
Query with parameters
44
44
44
120
45
45
R
Reading data (process)
Re-arranging the blocks
Rectangle
Registration card
Removing a column (table)
Report
3 Dimensions
Associated keywords
Associated properties
Available Types
Blocks
Bound
Calculations
Close
Composite report
Creation
Data Source
Description
Form
Format
Functions
Languages
Margins
Nested report
Print
Processes
Programming
Report controls
Restore
Save
152
139
67
77
19
101
13
59
144
144
26
62
44
36
55
105
26
43
53
55, 56
37
146
55
37
108
39, 112, 115
138
137
70
55
37
Skin Template
Structure
Test
Using tables
With parameters
Report based on a memory zone
Print
Report based on a query
Print
Report based on a table control
Print
Report based on a text file
Print
Report based on a variable
Print
Report based on file
Print
Report based on HFSQL view
Print
Report Editor
Configuration
Developer Version
Documentation
Keyboard Shortcuts
Main Window
Registration Card
Setup
User Version
Report editor
Minimum configuration
Report on Form
Report template
Report with parameters
Create
Print
Test
Reports and Queries
Resizing the table cells
Ribbon (menu)
Ribbon menu
Row
Rport
Open
RTF
RTF file
Running a report
S
Save
37
15
37
93
141
128
120
122
130
124
115
126
19
18
18
23
20
19
18, 19
18
16
18
32
61
141
141
142
143
18
100
20
20
77
55
39, 74
39
115
Report
Scheduler (type of report)
Scheduler report
Search key
Select one or more controls
Shape
Skin template
Snap-on grid
Sort
Source of the report
Start of Document
Start of print (process)
Starting the report editor
Stored currency
Structure of a report
Style of the table
System date
System Time
37
30, 31
30, 31
44
82
77
37, 61
88
35
43
64
138
20
72, 73
15
55
75
75
Table control
Print the report
Table report
Table row
Selection
Test
Report
Report with parameters
Text file
Print the report
Type
Type of blocks
Type of controls
Type of report
99
37
143
39, 51
130
63
70
26
U
URL link
78
T
Table
Add a cell
Add a column
Characteristics
Create
Delete a column
Description
Inserting a table into a report
Move a column
Remove a column
Resize the cells
Select an element
Style
Table cell
Table description
Table (type of report)
Create
122
29
47
99
99
97
95
101
97
96
101
101
100
99
55
98
99
29
95
59
W
Wizard
Report creation
WLanguage variable
26
45
X
XML
XML file
39
39
Z
Zoom
86
153
154
PART 2
Query editor
157
158
1. INTRODUCTION
1.1 What is a query?
A query is used to interrogate a database in order to view, insert, update or delete data.
The structure of the query defines the data used.
A query can interrogate one or more data files.
The query editor allows you to easily create queries without programming.
159
For example, in the Sales Management application, you want to find out:
the orders placed in March 2006. You will have the ability to create a query to select the orders placed
between 03/01/2006 and 03/31/2006 in the ORDERS file.
The query named QRY_OrdersMarch2006 interrogates the ORDERS file.
the numbers of the orders placed by the customers who live in Seattle. You will have the ability to
create a query that interrogates:
- the CUSTOMER file to select the customers who live in Seattle
- the ORDERS file to display the order numbers
The query named QRY_OrdersSeattleCustomer interrogates two files (CUSTOMER and ORDERS).
160
1.2.2 Differences between the standard query editor and Reports & Queries
Two versions of the query editor are available:
the standard query editor included in the product.
This version is supplied with WinDev, WebDev or WinDev Mobile. This version can be used when developing a WinDev application, a WinDev Mobile application or a WebDev site.
the user version of report editor (also called Reports & Queries). This editor is supplied with WinDev
only.
This version is independent of WinDev and it can be used by the end users.
Some features of the query editor are not available in this version.
The icon
query editor.
indicates the differences between the user version of query editor and the standard
The standard query editor allows you to create queries and to run these queries from the editor or from an
application developed in WinDev, WinDev Mobile or WebDev.
The dongle is required to use the query editor. It must be plugged into the parallel port or into the USB port of
your computer when using the editor.
However, no dongle is required for end users to run a query from a WinDev, WinDev Mobile or WebDev application.
Several examples are supplied with the standard query editor. In these examples, you will discover the main
queries that can be used in your applications.
To find out the list of examples for using queries:
1. Display the guide (on the "Home" pane, in the "Online help" group, expand "Help" and select "See the
guide").
2. Enter the "Query" keyword and click "Go". The list of examples for using queries is displayed.
Take a look at these examples, they will teach you a lot and you will be able to use them when creating your
own queries!
User version of query editor (Reports & Queries - WinDev only)
Reports & Queries allows you to create and run queries from the editor (WinDev is not required).
The created queries can be run from the query editor or from a WinDev application (if this application supports the queries created by Reports & Queries).
No dongle is required to use Reports & Queries.
Some operations are required to create new queries or to modify existing queries with Reports & Queries. See
Distributing Reports & Queries, page 231 for more details.
161
Documentation
Reports & Queries and the standard query editor are supplied with the same online help. The standard query
editor is supplied with a printed documentation.
Printed documentation
The printed documentation (the guide you are reading) is intended to help you discover and use the query editor. The first part of this guide is dedicated to the report editor.
The "Query editor guide" complements the "WLanguage" manual, the "Tutorial" and the "Concepts" manual.
Online help
The online help is intended to help you handle the editor. The online help is proposed:
as a local help. The necessary files are installed on the development computer.
as an Internet help. This help can be accessed from any computer equipped with an Internet access. This
help is updated on a regular basis.
To access the online help:
on the "Home" pane, in the "Online help" group, expand "Help" and select "Summary" or "Index of the
help".
press the [F1] key from any editor.
To modify the type of online help used:
1. On the "Home" pane, in the "Environment" group, expand "Options" and select "General options of
XXX".
2. In the "Help" tab, select the access mode to the help database: "Use the help database by Internet" or
"Use the local help database" as well as the preferred language.
3. Validate.
Setup
The registration card supplied with your product is very important. It allows you to benefit from the free services proposed by PC Soft to its customers: free Technical Support, information about new releases, product
upgrades,
Fill and return your registration card today.
162
Ribbon
Gives quick access to the main features of the query editor. This ribbon includes panes, groups and options.
See A menu shaped like a ribbon, page 165 for more details.
SQL code of the current query
Graphic representation of the current query
Scrollbars are used to scroll the representation of the query if the size of this representation is quite important. You also have the ability to perform a zoom in the query editor according to a specified zoom factor:
on the "Display" pane, by modifying the zoom,
with the mouse: [Ctrl] + Mouse wheel.
163
Important
Panes
Displays:
the frequently used features ("Command" pane),
the elements (files, items, reports, controls, ) available in the current project ("Project explorer"
pane).
In Reports & Queries, only the accessible elements are listed in the "Project" pane.
Important
Description window of the current query ("Query description" from the popup menu of the query graph)
Allows you to find out and modify all the characteristics of the query.
Browser
When a query cannot be entirely displayed in the workspace, the browser enables you to easily move within
this query.
Opened documents
Displays a button for each document (reports, queries, ) opened in the editor. To display the requested element in the foreground, all you have to do is click the corresponding "button".
164
1.
WinDev/WebDev/WinDev Mobile button (top left). This button is used to display the "About" information of the current product.
2.
3.
4. Quick access buttons. These buttons correspond to the most often used options:
New, Open,
Save,
Go of project,
Go of window or page,
5. Ribbon panes. These panes are used to access the different options.
7.
Group button. Button found at the extremity of a group used to perform a specific action (display
the options of the current element, display the help, ).
8. Ribbon options. Several types of options are available in the ribbon:
Buttons to click
Options to check.
Button with arrow used to expand the options.
2 types of buttons with arrow are available:
- the buttons with arrow used to expand a menu.
- the buttons with arrow used either to expand a menu (click on the arrow),
or to perform a default action (click on the button icon).
165
Ctrl + Shift + W
Del
Shift + F8
Ctrl + F8
F2
Edit the code associated with the selected query in the "View code" pane
Ctrl + Shift + F2
Help
F1
Ctrl + W
Ctrl + N
Ctrl + O
Open a project
Ctrl + Shift + O
Ctrl + P
F9
Save
Ctrl + S
Save all
Alt + S
Save as
Ctrl + Shift + S
Select all
Ctrl + A
Stop the test mode (when running the test of the project or query)
Shift + F5
Ctrl + Z
Zoom + / -
166
Analysis
Query
Project
Queries
Windows
167
Important
Important
Update query: Used to modify records in a database file. See Update query, page 174 for more
details.
Important
Delete query: Used to delete records from a database file. See Delete query, page 176 for more
details.
Union query: Used to combine selection queries. See Union query, page 177 for more details.
Note: All types of queries can be based on items belonging to:
a data file described in the analysis.
a query that was created beforehand.
Insert, Update and Delete queries:
The ability to create Insert, Update and Delete queries is supported for compatibility with the SQL standard.
The use of native WLanguage commands (HReadFirst, HReadNext, HAdd, HModify, HDelete, ) is much
more suitable for programming this type of process.
SQL is a query language used to interrogate data but it is not well suited for custom modifications of this
data. To add, modify or delete records in a database file, the performance and the simplicity of WinDev and
WebDev are unmatchable.
168
Important
Principle:
To create a query, you must:
specify the method for creating the query (wizard/description window or SQL code).
specify the type of the query (insert, update, ).
specify (if necessary) the WinDev or WebDev analysis containing the description of the data files on
which the query will be based.
select the items to use.
enter the characteristics of the query (selection conditions, sort, ).
The following paragraphs present the different types of queries and their creation mode.
169
To perform this query, the result will be automatically grouped by customer name, by zip code and by city.
Selection
conditions
(see page 199 for more
details)
Sorting the records (see
page 197 for more
details)
170
Important
In Reports & Queries, the creation wizard asks all the necessary questions for creating a
query.
5. When the description of your query is validated, the graphic representation of the query is automatically displayed in the query editor.
Notes:
You also have the ability to create a new Select query via a simplified wizard: check "Use the simplified
wizard" in the wizard for query creation.
Note: The simplified wizard cannot be used to manage the "full-text" indexes.
You have the ability to modify all the characteristics of a query ("Query description" from the popup
menu of the query). See Characteristics of a query, page 194 for more details.
To generate the SQL code corresponding to this query, select "SQL code" from the popup menu of the
query. If modifications are performed in the description of the query, these modifications will be automatically carried over into the corresponding SQL code.
You can also create a query from one or more data files described in the data model editor: to do so,
Drag and Drop the data files selected in the "Analysis" pane to the query editor.
The test of the created query can be run from the query editor. See the Test of the query, page 208
for more details.
171
Important
An Insert query (corresponding SQL command: INSERT) is used to add records into a database file.
This query generates the following SQL code ("SQL code" from the popup menu of the query) :
INSERT INTO Customer
( Title, CustomerName, Address1, ZipCode, City )
VALUES(Miss, Montgomery, 225 half Moon Walk, 34125, Miami,
"Florida" )
172
173
Important
An Update query (corresponding SQL command: UPDATE) is used to modify records in a database file.
This query generates the following SQL code ("SQL code" from the popup menu of the query):
UPDATE Customer
SET Title = Mrs, CustomerName = Clark
WHERE Customer.CustomerNum = 45762
174
175
Important
A Delete query (corresponding SQL command: DELETE) is used to delete records from a database file.
This query generates the following SQL code ("SQL code" from the popup menu of the query):
DELETE FROM ORDERS
WHERE ORDERS.OrderDate < 20000101
176
177
The records common to the two files ("Customer" and "Prospect") can:
appear once only in the result of the query (UNION operator).
appear twice in the result of the query (UNION ALL operator).
To combine queries, you must know:
the name of the queries to combine.
whether the common records must appear once or several times in the result of the query.
Note: The items displayed in the result of the Union query correspond to the items of the first query run. Therefore, in our example, the people who are both customer and prospect, whose name starts with the letter A
and who live in Paris will only appear once in the result of the query.
This query generates the following SQL code ("SQL code" from the popup menu of the query):
SELECT CUSTOMER.CustomerLName AS CustomerLName
FROM CUSTOMER
WHERE CUSTOMER.CustomerName LIKE A%
UNION
SELECT CUSTOMER.CustomerLName AS CustomerLName
FROM CUSTOMER
WHERE CUSTOMER.City LIKE Paris
In order for the people who are both customer and prospect, whose name starts with the letter A and who
live in Paris to appear several times in the result of the query, the SQL code must be:
SELECT CUSTOMER.CustomerLName AS CustomerLName
FROM CUSTOMER
WHERE CUSTOMER.CustomerName LIKE A%
UNION ALL
SELECT CUSTOMER.CustomerLName AS CustomerLName
FROM CUSTOMER
WHERE CUSTOMER.City LIKE Paris
178
Important
The previous paragraphs explained how to create a query with the wizard. The query editor also allows you to
create a query in SQL code directly (if you are familiar with this language).
The following SQL commands are not allowed in Reports & Queries:
INSERT
UPDATE
DELETE
179
4. Enter the name of the query (name of the ".WDR" file corresponding to the query). This name will be
used to identify the query in your programs.
5. Specify the caption of the query by briefly describing the purpose of the query. This caption will be
used in the project documentation.
Note: The name of the query is automatically defined from the caption.
6. Validate the query creation. A code window is displayed.
7. Enter the SQL code of your query. You have the ability to insert into the query:
comments by writing the "--" or "//" character in front of them. Only the comments about the selection
conditions will be taken into account during the reverse engineering of the query: the other comments
will be automatically deleted. The comments about the selection conditions with parameters will not
be proposed when running a GO of the query.
WLanguage functions. The WLanguage functions must be prefixed by "WL.". The assisted input is
available. The WLanguage functions can be nested. Example:
SELECT CUSTOMER.CustomerNum FROM CUSTOMER
WHERE WL.Left(Customer.ZipCode,2)=75
180
ALL
ALTER TABLE
AND
ANY
AS
Creates an alias for each item and for each data file used
ASC
ASCII
Returns the ASCII code of a character or the ASCII code of the first character
in a string.
ATAN
AVG
BETWEEN
Selects the records for which the value of an item belongs to a range of
values
BIN
BOTTOM
CASE
CAST
CBRT
CEIL / CEILING
CHAR
CHAR_LENGTH
CHARACTER_LENGTH
CHR
COALESCE
CONCAT
COUNT
CREATE INDEX
CREATE
MATERIALIZED VIEW
181
CREATE TABLE
CREATE VIEW
DECODE
DEGREES
DELETE
DESC
DISTINCT
Used with the SELECT statement: Deletes the duplicated records (duplicates)
from the query result
DIV
DROP
VIEW
182
MATERIALIZED
DROP TABLE
DROP VIEW
ELT
EXISTS
EXTRACTVALUE
Used to handle XML strings. Returns the text (CDATA) of the first text node that
is a child of the element corresponding to the XPATH expression.
FIELD
Returns the index of the sought string in the list. If the string is not found, the
function returns 0.
FROM
Performs an outer join. See the online help for more details.
GRANT
GREATEST
GROUP BY
HAVING
HEX
IN
INITCAP
Returns a string containing the first letter of each word in uppercase characters.
INNER JOIN
INSERT
Used to add the records returned by a SELECT query into a data file.
INSTR
INTO
Used with the INSERT statement: Defines the data file used
IS NULL
IF NULL
LAST_DAY
Calculates the date of the last day for the specified month
LAST_INSERT_ID
LCASE
Returns a string with all the characters in lowercase according to the current
character set.
LEAST
LEFT
Extracts the first characters from the content of a file item or character string
Performs an outer join. See the online help for more details
LEN
LENGTH
LIKE
Selects the records for which the value of an item corresponds to a specified
value (with wildcard characters)
LIMIT
LOWER
LPAD
LTRIM
MAX
Returns the greatest value of an item for all the records selected in the data
file
MD5
MID
MIN
Returns the lowest value of an item for all the records selected in the data file
MONTHS_BETWEEN
NEW_TIME
NEXT_DAY
Returns the first day of the week following the specified date or day
183
184
NOT
NVL
OCT
OCTET_LENGTH
ON
Used when creating a join. See the online help for more details
OR
ORDER BY
PATINDEX
POSITION
RADIANS
RANDOM
REPEAT
REPLACE
REVERSE
REVOKE
Used to remove the rights (they are switched to hInherit) on a HFSQL server
RIGHT
Extracts the last characters from the content of a file item or character string
Performs an outer join. See the online help for more details
ROUND
RPAD
Returns a string of a given size. To reach the requested size, the string is filled
on the right:
by space characters.
by a character or by a given string.
RTRIM
SELECT
SET
SHA, SHA1
Calculates the 160-bit SHA1 check sum of the string passed in parameter
according to the RFC 3174 standard (Secure Hash Algorithm).
SOME
SOUNDEX2
SOUNDEX2_LIKE
SOUNDEX
SOUNDEX_LIKE
SPACE
SPLIT_PART
STDDEV
STDDEV_POP
Used to find out the standard deviation of a series of values representing the
full set of data.
STDEV_SAMP
STRING_AGG
SUBSTR
SUBSTRING
SUM
Returns the sum of values of an item for all the records selected in the data
file
SYSDATE
TO_CHAR
TOP
TRANSLATE
Returns a character string with all the specified characters replaced by other
characters
TRIM
185
TRUNC
UCASE
Returns a string with all the character in uppercase according to the current
character set.
UNHEX
UNICODE
Returns the integer value defined by the Unicode standard of the first character in the specified expression.
UNION
UPDATE
UPPER
UUID
VALUES
VAR_POP
VAR_SAMP
VARIANCE
WHERE
To switch from the embedded mode to the independent mode (which means to extract a query from a control):
1. Display the window or the page in the editor.
2. Select the control.
3. Select "Embedded query .. Open the associated query" from the popup menu of the control. The query
is displayed in the query editor.
Caution: The window or the page must have been saved at least once.
4. On the "Home" pane, in the "General" group, expand "Save" and select "Export .. To an independent
query".
5. Save the new query. The query is now an independent query.
187
3. DESCRIPTION OF A QUERY
3.1 Overview
The steps for creating a query have been explained in the previous chapters. Once a query is created, all the
characteristics of this query can be modified at any time:
data files and/or items used,
items displayed in the query result,
selection conditions,
sort of records,
Only the type of the query cannot be modified. Indeed, too many specific parameters are taken into account.
To change the type of the query, all you have to do is create a new query.
This chapter presents:
the description window of a query.
the characteristics of a query.
how to open, close and save a query.
the management of query versions.
188
Note: The floating help of this window (green and transparent) is automatically displayed. The floating help is
displayed when the mouse cursor does not move. To remove this help:
for the current session: press [Alt]+[F1] simultaneously.
permanently:
1. Display the configuration options of the query editor: on the "Home" pane, in the "Environment"
group, expand "Options" and select "Options of query editor".
2. Check "Dont display the floating help".
3. Validate.
189
Important
The data files and the file items that can be used in Reports & Queries are defined in the
data model editor. See Distributing Reports & Queries, page 231 for more details.
Used to add/delete the selected items to/from the query. The selected elements are displayed in the
middle section.
Adds a new item to the query result. This item corresponds to a calculation on some items that can be
used in the query.
For example, the "PriceIOT" item corresponds to the "PriceBT" item multiplied by the "VATRate" item.
Displays:
the query in natural language.
the SQL code corresponding to the query.
190
List of items used in the query. See Items used in a Select query, page 194 for more details.
The values of this item will be displayed in the result of the query (
Sort direction for the values of this item (ascending
).
, descending
).
191
Right section: This section is used to define the different actions that must be applied to the query
items. See Characteristics of a query, page 194 for more details.
192
Used to:
manage the joins (add, modify, delete, reinitialize).
check (or not) the SQL syntax used (in test mode only).
193
Used to keep or delete the duplicated records (duplicates) from the result of the Union query.
List of result items for the Union query.
Note: These items correspond to the items of the first query run.
Used to perform or cancel the sort on a query item.
Displays:
the Union query in natural language.
the SQL code corresponding to the Union query.
Important
The description window of a query (Insert, Update or Delete) or the description window of a query in SQL code
is used to:
find out and/or modify the name and the caption of the query.
specify whether the SQL commands used must be checked (or not) by the HFSQL engine ("Run with
hQueryWithoutCorrection in test mode").
specify the connection used when running the test of the query.
find out and/or modify the values to insert or to modify in the result of the query (Insert query or
Update query).
find out and/or modify the selection conditions (Update query or Delete query).
find out and/or modify the sequence of selection conditions (Update query or Delete query).
194
"calculated" items.
This type of item is used to add to the query result an item whose value corresponds to a calculation
on items. For example, PriceBT * VATRate.
The items taking part in a query are chosen when creating the query. However, you have the ability to add,
modify or delete the items used in a query. These operations are described in the following paragraphs.
Note: The items whose value is displayed in the query result are called result items.
To add an item into the current query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the left section of the window, double-click the item to add. This item is displayed in the middle section of the window.
To perform a full-text search:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the left section of the window, double-click the "FullText_Index" item to add. The description window
of the search is displayed.
3. Specify the parameters of the full-text search to perform:
the index used
the search value (value or parameter). If the value is described in the query, a wizard allows you to
enter all the necessary conditions on the search value.
the sort of the query result according to the relevance subscript of the search for each record.
Note: only the records whose relevance subscript is greater than 0 are kept in the result of the query.
To add a count item into the current query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the right section of the window, click the "Count" button.
3. To count:
the number of values for the selected item in the query result: select "On the selected item".
For example, this option can be used to find out the number of customers who have a cell phone ("CellPhone" item filled).
the number of values for another item in the query result: select "On another item" and select the
requested item.
the number of records in a data file or in a query (according to the selection conditions of the current
query): select "On a file or query".
For example, this option can be used to find out the number of products found in the "Product" file.
Note: Regardless of the count performed, you have the ability to specify whether the duplicates must be
taken into account (or not) by the count (Count(Distinct) in SQL).
195
Notes:
Deleting an item also deletes the selection conditions defined for this item.
To delete an item, you can also select "Delete the item" from the popup menu of the item.
196
Note: The digits found beside the arrows can also be used to find out the sequence of the different sort
items.
For example, in the window below, the result of the query is sorted:
on the total amount of orders first,
then on the city of customers,
finally on the name of customers.
The arrows found on the right of the list are used to modify the sequence of sort items.
Note: Only the items displayed in the query result can be sorted.
The sort order is defined when creating the query. However, you have the ability to:
add or delete a sort on an item,
modify the sort order performed on an item.
These operations are described in the following paragraphs.
To add a sort on an item in the current Select query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the middle section of the window, select the requested item.
3. In the right section of the window, click the "Sort" button and select "Sort on the selected item".
4. Specify the sort order and validate.
To delete a sort on an item in the current Select query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the middle section of the window, select the item for which the sort must be deleted.
3. Display the popup menu of this item (right mouse click).
4. Select "Sort the item .. Dont sort".
197
The operations are defined when creating the query. However, you have the ability to add, modify or delete
the operations performed in a query. These operations are described in the following paragraphs.
Caution: If the query result is displayed in a report, the operations to perform on the value of items must be
defined when describing the report. See the How do I create a report?, page 25 for more details.
To add an operation into the current Select query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. In the middle section of the window, select the item on which an operation must be performed.
3. To calculate:
the sum of values for this item, click the "Sum" button.
the mean of item values, click the "Average, Max, Min" button and select "Average".
the maximum value for all the item values, click "Average, Max, Min" and select "Maximum".
the minimum value for all the item values, click "Average, Max, Min" and select "Minimum".
4. Validate. The operation is automatically added into the query.
198
199
You can:
select one of the possible values among the ones found in the data file.
view the entire data file.
Caution: This option is available only if the Live Data is enabled. The Live Data is configured in the "Live
Data" tab of the project properties. See the online help (keyword: "Live Data") for more details.
5. Indicate (if necessary) a comment on the condition. This comment will be displayed in the SQL code of
the query (preceded by "//").
6. Validate. The selection condition is automatically added to the query.
To add a selection condition into the current Update or Delete query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. Display the "Query" tab.
3. Select the item onto which a selection condition must be added and click the corresponding "Condition" column. The wizard for creating a selection condition is displayed.
4. Select (if necessary) "I want to add a condition" (for an item on which at least one condition is performed).
5. Choose the selection criteria (equal to, greater than, ) of the condition. This condition can be applied
to a given value, a parameter, a sub-query,
6. Indicate (if necessary) a comment on the condition. This comment will be displayed in the SQL code of
the query (preceded by "//").
7. Validate. The selection condition is automatically added.
How do I modify a selection condition in a query?
You can:
select one of the possible values among the ones found in the data file.
view the entire data file.
Caution: This option is available only if the Live Data is enabled. The Live Data is configured in the "Live
Data" tab of the project properties. See the online help (keyword: "Live Data") for more details.
200
6. Indicate (if necessary) a comment on the condition. This comment will be displayed in the SQL code of
the query (preceded by "//").
7. Validate. The selection condition is automatically modified.
To modify a selection condition in the current Update or Delete query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed.
2. Display the "Query" tab.
3. Select the item on which a selection condition must be modified and click the corresponding "Condition" column. The wizard for selection conditions is displayed.
4. Select "I want to modify an existing condition".
5. Select (if necessary) the condition to modify (for an item on which several conditions are performed).
6. Modify the selection condition.
7. Indicate (if necessary) a comment on the condition. This comment will be displayed in the SQL code of
the query (preceded by "//").
8. Validate. The selection condition is automatically modified.
How do I delete a selection condition from a query?
201
Conditional OR operator
Two methods can be used to modify the sequence of selection conditions in the current query:
1st method: Via the description window of the query
202
To display the records corresponding to a given period in the current Select query:
1. Select "Query description" from the popup menu of the query. The description window of the query is
displayed
2. In the middle section of the window, select a "Date" item.
3. In the right section of the window, click "Between two dates".
4. Specify the start date and the end date, then validate.
Note: For the "DateTime" items, when the start date and the end date correspond to values, the query editor
proposes preset periods (current month, previous week, floating year, ). To use one of these preset periods,
click the "Preset period" button and select the requested period.
203
Note: The links between the data files are displayed in the graphic representation of the query only if the linked data files are used by the query.
By default, the joins are automatically created by the query editor. However, these joins may not correspond
to the requested result. You have the ability to modify or delete the joins. These operations are described in
the following paragraphs.
204
To add a join into the current Select query (that already includes a join):
1. Select "Edit the join" from the popup menu of the join. The description window of the joins is displayed.
2. Click the "Add" button. A window allowing you to define a new join is displayed.
Note: The "Modify" button is used to modify the selected join.
3. Specify the characteristics of the join to add.
4. Validate. The join is automatically added into the query.
This gives you the ability to create multiple joins between two data files.
To delete a join from the current Select query:
1. Select "Edit the join" from the popup menu of the join. The description window of the joins is displayed.
2. Select the join to delete.
3. Click the "Delete" button. The join is automatically deleted. The joins between the data files are optimized in order for the query to operate properly.
205
Important
The query editor allows you to optimize the execution speed of one or more queries found in your project.
The optimization of a query is based on the following principle: a wizard defines the composite keys that must
be modified and/or added in the analysis associated with the project.
Reports & Queries cannot be used to optimize the execution speed of a query.
207
When running the test of the query, the initialization code of the project is run.
Notes:
Several tests of different queries can be run at the same time.
Important
The button
is used to automatically display the mean, the total, the maximum value and the
minimum value of the numeric result items.
208
When running the test of a query with parameters, a window used to specify the different parameters is displayed. See the Query with parameters, page 216 for more details.
Password
If one of the data files involved in the query is password protected, during the test of the query:
if the password is specified in the initialization code of the project (HPass), the query is run.
if the management of HFSQL errors was not customized (HOnError) and if the password is not specified by programming, the standard window for password input is displayed.
Note: if the management of errors is customized in the initialization code of the project, this management of errors will be used.
Test of a query without checking the SQL code
For the queries that are using data files accessed via a Native Access or via an OLE DB provider, the HFSQL
engine may perform no query check.
See Runtime modes of a query in SQL code, page 180 for more details.
209
3. Choose the type of separator used between the different items of each record ("Type"):
- Separator: Tabulation: The items will be separated by tabulations.
- Separator: Semicolon: The items will be separated by semicolons.
4. Validate. The records found in the query result are automatically exported to a RTF file.
210
3. Validate. The records found in the query result are automatically exported to the XML file. An XSL style
sheet is automatically generated.
Important
The result of an Insert, Update or Delete query can only be used in a program.
Reminder: Reports & Queries cannot be used to create:
Insert queries.
Update queries.
Delete queries.
See Running the query and handling the result with the WLanguage functions, page 213 for more details.
211
Important
A query can be used as data source for a window or for a page. The window or the page will display the
records selected by the query.
The queries created with Reports & Queries can be run from a WinDev application only if
this application supports the queries created by Reports & Queries.
Important
A query can be used as data source for a control. The control will display the records selected by the query.
The queries created with Reports & Queries can be run from a WinDev application only if
this application supports the queries created by Reports & Queries.
To display the result of the query in a list box, combo box, looper or table:
1. Open the window or the page where the list box, combo box, looper or table must be added.
2. Insert the control associated with the query (the different controls can be created in the "Creation"
tab). The wizard for control creation starts.
3. Specify that the information displayed in the control comes from an existing query.
4. Select the query that must be associated with the control and the items that must be displayed in the
control.
212
5. Validate. The created control will display the information coming from the associated query.
6. Enter (if necessary) the following code line in the initialization process of the control. This code line is
used to initialize and run the query, and to display the result of the query in the current control.
HExecuteQuery(<Name of associated query>)
To use the result of the query in a control (other than a list box, combo box, looper or table):
1. Open the window or the page where a control associated with a query must be added.
2. Create the control associated with the query.
3. Display the description window of the control ("Description" from the popup menu).
4. Display the "Link" tab in the description window of the control.
5. Select the item to display in "Linked item".
6. Validate. The created control will display the information coming from the associated query.
7. Enter (if necessary) the following code line in the initialization process of the control. This code line is
used to initialize and run the query, and to display the result of the query in the current control.
HExecuteQuery(<Name of associated query>)
Note: When creating a table control associated with a query, you can:
1. Select the query in the "Project explorer" pane.
2. Perform a Drag and Drop toward the window. A table associated with the query is automatically created in the window or in the page.
4.3 Running the query and handling the result with the WLanguage
functions
The result of a query is not necessarily displayed in a report, in a window, in a page, ... This selection can also
be used in programming.
Most of the HFSQL functions (browse, search, read, ) can be used both on data files and on the query
result. To use these functions on a query, the query must be run beforehand (HExecuteQuery).
For example, the Customer34 query selects the customers whose zip code starts with 34. The PrintCustomer
procedure is used to print a proforma invoice for each customer. The following code is used to browse the
result of the Customer34 query and to print an invoice for all the selected customers.
213
Password
If the query is linked to a password-protected analysis, this password must be specified when the analysis is
opened (HOpenAnalysis) in the initialization process of the project.
If the query is based on one or more password-protected files, these passwords must be specified via HPass
before running the query (HExecuteQuery).
214
5. ADVANCED QUERY
5.1 Overview
The steps for creating "Simple" queries have been explained in the previous chapters. The query editor can
also be used to create advanced queries. You have the ability to:
use the query result in another query. This is the concept of sub-queries.
use parameters in a query. The value of these parameters will be specified when running the query.
This is the concept of query with parameters.
5.2 Sub-query
A sub-query is a query whose result is used by another query.
For example, you want to select the orders whose total amount is greater than the average amount of orders.
The average amount of orders is not directly known. This average amount will be returned by another query
(called sub-query).
A sub-query can be used:
as selection condition,
as data source for the main query.
Limits:
The sub-queries cannot be created in the query editor.
The ORDER BY statement is not allowed in the sub-queries
215
Example: The following SQL code is used to select the order number of the orders whose total amount is
greater than the average amount for all the orders:
SELECT OrderNum
FROM ORDERS
WHERE Amount > (SELECT AVG(Amount)
FROM ORDERS)
216
3. Specify the value of the parameters that will be used to run the test of the query.
Note: You have the ability to select a specific value via
. The following menu is displayed:
You can:
select one of the possible values among the ones found in the data file.
view the entire data file.
Caution: This option is available only if the Live Data is enabled. The Live Data is configured in the "Live
Data" tab of the project description. See the online help (keyword: "Live Data") for more details.
4. Validate. The result of the query is displayed according to the specified values.
Note: If no parameter is selected (parameter not checked), the conditions that use the parameters will be
ignored.
Principle
When creating a window (or a page), this window (or this page) can be based on a query with parameters. The
parameters of the query can be entered in a previous window (or page) for example.
To use a window (or a page) based on a query with parameters, the query must be run (HExecuteQuery):
before opening the window (or the page).
in the declaration code of the global variables of the window (or page).
The necessary parameters must be passed when running the query. These parameters can be passed:
in HExecuteQuery directly.
by using the following notation <Query name>.<Parameter name>, then by using HExecuteQuery.
See the Two methods for passing parameters to a query, page 220 for more details.
Example
To display the list of orders placed in year XXXX, the user performs the following operations:
type the requested year in the WIN_EditParam window.
click the "Show the result" button. The WIN_OrderList window is displayed. This window is based on the
QRY_QryParamOrder query. This query is used to select the orders placed on the date specified by the
user.
The following code is used to:
open the WIN_EditParam window,
retrieve the value entered by the user,
run the QRY_QryParamCustomer query.
217
1. Opening the window for entering parameters in the initialization process of the WIN_OrderList window:
-- Initialization process of WIN_CustomerForm window
QRY_ParamQuery is string
// Open the WIN_EditParam window
// retrieve the input performed by the user
QRY_ParamQuery = Open(WIN_EditParam)
Using a query with parameters in a table, a looper, a list box, a combo box
Overview
A table, a list box, a looper or a combo box can be used to display the content of a data file or query.
A table, a list box, a looper or a combo box can be linked to a query:
independent. This query already exists in the project: select this query among the queries of your project.
embedded in the table, list box or combo box: this query will be created in the wizard for creating the Table
control. This query will be available for this control only and it will be saved with the window that is using it.
In this case, the window contains all the necessary elements.
with parameters: this independent or embedded query requires parameters in order to be run and to display the result in the table.
Note: this paragraph only presents the tables but the operating mode is similar for the list boxes, the combos
boxes and the loopers.
Browsing tables based on independent queries
A browsing table based on an independent query (without parameter) displays the records of this query.
By default, the query is run and loaded in memory during its first use. The result of a query used in a browsing
table remains in memory when closing the associated window or page. This query will not be re-run when it is
re-used.
To re-run this query, you must use:
HCancelDeclaration:
If HCancelDeclaration is not called, the next initialization of the table control (re-opening the window
for example) will not re-run the query. The data retrieved during the last query execution will be used. If
the table is based on a query with parameters, see "Browsing table based on a query with parameters
(embedded or not)".
If HCancelDeclaration is called, the next initialization of the table control (re-opening the window for
example) will re-run the query.
TableDisplay (or ListDisplay for a list box): to force the re-execution of the query, use TableDisplay associated with the taReExecuteQuery constant.
218
In this case, the query is automatically run when initializing the table.
Note: you also have the ability to use one of the following notations:
- MySource:
MySource.<Name of Parameter1> = xxx
MySource.<Name of Parameter2> = xxx
MySource.<Name of Parameter3> = xxx
- the indirection:
{"<Query Name>.<Name of Parameter1>"} = xxx
or
{"<Query Name>"}.<Name of Parameter1> = xxx
HExecuteQuery.
One of these two methods can be used in the declaration code of the global variables of the window or in the
initialization code of the table.
Special cases:
Initializing a Table control or using TableDisplay without the taReExecuteQuery constant.
If no query parameter was modified since the last query execution, the query is not re-run. The table
will display the records corresponding to the last query execution.
Once the query parameters are modified, TableDisplay (or ListDisplay for a list box) is used to re-run
the query. The table displays the records corresponding to the specified parameters.
Using TableDisplay with the taReExecuteQuery constant.
To force the re-execution of the query, use TableDisplay (or ListDisplay for a list box) associated with the
taReExecuteQuery constant.
Reminder: the structure of the query parameters being re-initialized whenever the query is run, dont forget
to redefine the requested parameters before using this function.
219
Principle
To use a report based on a query with parameters, the query must be run before opening the report. The
query can be run by iInitReportQuery. This function is used to run the query and to pass parameters to this
query. This function can be called:
in the initialization code of the report,
before iPrintReport.
Example
The WIN_CustomerForm window is used to browse the characteristics of customers. For each customer, the
user can click the BTN_PrintOrder button to print the RPT_CustomerOrdReport report. This report is associated with the QRY_QryCustomerOrd query that selects the orders placed by a given customer.
The following code is used to run the QRY_QryCustomerOrd query according to the current customer and to
print the report:
-- Click process of BTN_PrintOrder button
// Run the query according to the current customer
iInitReportQuery(RPT_CustomerOrdReport, NUM_CustomerNum)
// Print the report
iPrintReport(RPT_CustomerOrdReport)
In most cases, the parameters passed to a query with parameters are entered by the user in edit controls.
In order for your query to be run even if no value was entered by the user, check "NULL if empty" for the edit
controls ("Details" tab of the control description).
When this option is checked, if the edit control is empty, the value of the parameter passed to the query will
correspond to the NULL constant. No error will occur when running the query: the conditions that depend on
this parameter will be ignored.
For example, the SQL code run is:
SELECT NameOfItems
FROM NameOfFiles
WHERE Item = {Param1}
In this example, the table below describes the use of "NULL if empty":
Value entered by
the user
No value
Option checked
SELECT NameOfItems
FROM NameOfFiles
No value
Option unchecked
SELECT NameOfItems
FROM NameOfFiles
WHERE Item =
A value is entered
220
Note: If the query with parameters is used in a report, the mode for passing parameters changes. See Using
a query with parameters, page 217 for more details.
Using HExecuteQuery to pass parameters to a query
When running a query with HExecuteQuery, the last parameters passed to the function correspond to the
parameters of the query.
The syntax used is as follows:
<Result> = HExecuteQuery(<Query Name> [, <Connection>] [, <Mode>
[, <Parameters> [, ]]])
To pass parameters to a query, all the query parameters can be specified to the HFSQL engine before running
the query. This method allows you to specify the parameters in any order (useful for the queries that require
several parameters).
The following syntax must be used:
<Query name>.<Name of parameter
<Query name>.<Name of parameter
Caution:
The name of the parameter must be the name specified when the query was created in the query editor. This name must differ from an item name.
No indirection operator and no dynamic compilation (Compile) can be used with this syntax.
The parameters are reinitialized (reset to 0) whenever the query is run by HExecuteQuery.
If at least one parameter is specified in HExecuteQuery, all the parameters specified beforehand will
be ignored.
The value of the parameter can correspond to NULL.
If one of the parameters is not specified, the corresponding condition is ignored.
Avoid specifying all the parameters
Regardless of the method used to pass parameters to the query, all the query parameters do not necessarily
have to be specified. The query conditions that use unspecified parameters will be ignored.
For example: lets consider a query ("Customers_LName_FName") whose SQL code is as follows:
SELECT * FROM CUSTOMER WHERE LNAME= {Param1} AND FNAME = {Param2}
221
222
INDEX
A
Documentation
Duplicates
Add
Item
Join
Operation
Selection condition
Sort on an item
Automatic retrieval
195
205
198
199
197
205
C
Calculation
Characteristics of a query
Closing a query
Combining queries
Combo box
Use a query with parameters
Consistency with the analysis
Count
Creation
Query
Embedded query
Excel
Exporting the query
186
210
209
F
File
198
194
205
177
218
205
194
168
D
DELETE
Delete
Item
Join
Operation
Records
Selection condition
Sort on an item
Delete query
Creation
Description window
Selection condition
Test
Description
Description window
Display
First N records
Item
Last N records
206
204
176
196
205
199
176
201
197
176
177
194
199
208
188
203
196
203
Excel
XLS
XML
Full-text
Full-text search
210
210
210
195
195
G
Given period
203
H
HExecuteQuery
HExecuteSQLQuery
hQueryWithoutCorrection
213
213
180
I
Independent query
INSERT
Insert query
Creation
Description window
Test
Inserting records
Interface
Query editor
Item
Count
Operation
Selection condition
Sort
186
172
172
173
194
208
172
163
194
194
198
199
197
223
J
Join
Q
204
205
205
Add
Delete
K
Keyboard (shortcuts)
Keyboard shortcuts
166
166
L
List box
Use a query with parameters
Looper
Use a query with parameters
218
218
M
Menu
Ribbon
Mode of query
Modify
Displayed values
Selection condition
Sequence of conditions
163
186
199
200
202
O
Open
Query
Operation
Add
Delete
Optimizing the execution speed
205
198
198
199
207
P
Page
217
Using a query with parameters
Pane
164
Parameters
216
Pass parameters
220
Password
209, 214
Print
Documentation
206
Result
211
Print area
206
Project
167
224
Query
Advanced query
Automatic retrieval
Available types
Characteristics
Close
Consistency with the analysis
Create
Creation mode
Definition
Delete
Delete query
Description
Documentation
Duplicate
Embedded
Embedded query
Execution
Export
First N records
Independent
Independent query
Insert
Insert query
Item
Join
Last N records
Open
Operation
Optimize the execution speed
Overview
Print
Print area
Rename
Reverse engineering
Save
Select
Select query
Selection condition
SQL code
Sub-query
Test
Union
Union query
Update
Update query
Use
215
205
168
194
205
205
168
186
159
176
176
188
206
204
186
186
213
209
203
186
186
172
172
194
204
203
205
213
207
159
211
206
205
180
205
169
169
199
179
215
208
177
177
174
174
211
Use in a control
Use in a report
Use in a window
Use with the WLanguage functions
With parameters
Query and project
Query Editor
Developer Version
Documentation
Minimum configuration
Setup
User Version
Query editor
Interface
Main window
Query in SQL code
Available SQL commands
Creation
Runtime mode
Query with parameters
Create
Pass parameters
Test
Use
Use in a control
Use in a page
212
213
212
213
216
167
Use
Reverse engineering
Ribbon
Run the test
161
162
162
162
161
161
163
163
179
181
179
179
216
216
220
216
217
218
217
Save
R
Record
Delete
First N records
Insert
Last N records
Modify
Select
Registration card
Rename
Item
Query
Report
Use a query in a report
Report editor
Registration card
Result
Export to an Excel file
Export to an XML file
Modify the displayed values
Print
176
203
172
203
174
169
162
196
205
213
162
210
210
199
211
211
180
163
208
S
Query
SELECT
Select query
Description window
Duplicate
Given period
Item
Join
Modify the displayed values
Possible operations
Record sort
Selection condition
Test
Selection condition
Add
Delete
Modify
Sequence
Use a sub-query
Selection of records
Sequence
Given period
Sequence of selection conditions
Modify
Sort
Add
Delete
Sort order
SQL
SQL commands
SQL command
Start the query editor
Sub-query
System lockup
205
169
169
188
204
203
194
204
199
198
197
199
208
199
199
201
200
202
215
169
203
202
202
197
197
197
197
179
181
181
163
215
205
T
Table
Use a query with parameters
Type of queries
218
168
225
U
UNION
Union query
Creation
Description window
UPDATE
Update
Records
Update query
Creation
Description window
Selection condition
Test
226
211
W
Window
Main window of the editor
Use a query in a window
Window control
Use a query in a control
WLanguage
163
212
212
213
X
XML
210
PART 3
Reports &
Queries
231
236
239
229
230
231
232
233
234
Notes:
If the download package is found at the root, write "." in the Dir entry.
The name of the file to download is "WD200PACKER.exe".
235
236
).
).
If the query is used as data source for a report, the modified query will be automatically included in the
report.
Other query
237
238
239
240