Database Tour Documentation | |
Report Expressions |
Expression is a user-defined function, which returns a value. Expressions allow to do dynamic calculations during report generation and to output the results of the calculations. Report expressions are used in the following cases:
Rules for writing expressions are similar to rules of Pascal programming language. Expressions are calculated using general rules for arithmetic, logical and string expressions. Expressions can consist of:
For example, to include a field value, use dataset_field_val function. To include a SQL query parameter value, use dataset_param_val function. There is an ability to use expressions with dynamic and static parts. Dynamic parts begin with three opening triangle brackets (<<<) and end with three closing triangle brackets (>>>). When expression contains dynamic parts, then only these parts will be parsed and calculated during the report generation, and other parts of the expression will be interpreted as constants and therefore will not be parsed. When expression does not contain dynamic parts, the report engine will try to parse the full expression. Using dynamic parts is shown in example 17. It is possible to type expression directly or build it with expression builder (use '...' button for this), where you can select needed items like field names, functions etc. to add them in the expression. Once you have selected an item, click Add button. The resulting expression is shown in lower part of the window. You may edit it manually if it is needed. After you done, click OK to apply the expression to selected report object(s). Notes 1. Expression should return one value: numeric, Boolean (i.e. True or False), or text. 2. Expressions are calculated just before they are displayed in report. 3. String constants should be enclosed in single quotes. 4. Floating point constants must use '.' as decimal separator. 5. When using constants, variables, or functions of different types in one expression, to avoid type mismatches, it is recommended to explicitly convert the corresponding operands using to_string or to_number functions, as shown in example 10. |
See also |