[Database.Values:]
Inserts values from a single row from an SQL query.
This macro is partially execute-restricted. Details in the Usage / Parameters section. See Connection Role Security and / or Restricted Macros.
Purpose
Inserts values from a single row from an SQL query. Every column must have a name. The query is executed via a Database Connection. Note that the column names are automatically stored as variables so a [String:] macro, for example, is actually required to view the value(s) returned.
Macro Compatibility
The macro can be used in all input document types and in Report Studio.
Usage
Queries that contains the following commands (case-insensitive) are execute-restricted - in this case ask your Tenant Admin to make the Schedule admin-locked, and ensure an Admin has made the Connection accessible to you. The restricted commands are: ADD, ALTER, APPEND, BACKUP, CREATE, DELETE, DROP, EXEC, INSERT, TRUNCATE, and UPDATE.
Parameter | Type | Presence | Purpose | Options | Default |
---|---|---|---|---|---|
String | Mandatory | The SQL to execute - must return a single row. Queries that contains the following commands (case-insensitive) are execute-restricted - in this case ask your Tenant Admin to make the Schedule admin-locked, and ensure an Admin has made the Connection accessible to you. The restricted commands are: ADD, ALTER, APPEND, BACKUP, CREATE, DELETE, DROP, EXEC, INSERT, TRUNCATE, and UPDATE. | N/A | N/A | |
String | Optional | Add a comment to make your document template more readable. The comment is discarded in the output document. | N/A | N/A | |
String | Optional | The name of the Connection. | N/A | N/A | |
Boolean | Optional | Should NCalc expression evaluation throw error on Overflow |
|
true | |
String | Optional | The text to display should the macro fail to execute. Note that a poorly-specified macro (e.g. omitting mandatory parameters) will still result in an error message. | N/A | N/A | |
String | Optional | The condition that must be true in order for the macro to be executed/evaluated. Must either evaluate to true or false, for example: "3+5=8" or "contains('abcd', 'z'). | N/A | true | |
Int32 | Optional | The maximum number of attempts when requesting data. |
|
1 | |
MacroMode | Optional | The mode in which variables are stored. In the legacy mode (default for Schedules), the variable created is a string and formatted. In the normal mode (default for Report Studio), the output variable is stored as a strongly-typed object, e.g. an Int32 or a List |
|
Legacy | |
ObfuscationType | Optional | Obfuscation type. Use obfuscation to write reports where sensitive data is hidden. When used, ReportMagic guarantees that the same input string will map to the same output string for the whole of the report (but the next time the report runs, it will most likely map to a different value). If you use obfuscation, the property in your macro will not show up and instead, you will see a fake item of the obfuscation type chosen. |
|
None | |
Boolean | Optional | Whether to remove newline characters in the SQL before sending. |
|
false | |
Int32 | Optional | The timeout in milliseconds. Overrides the Connection's 'timeoutMs' parameter, if set. | N/A | N/A | |
String | Optional | Value to use if null is returned from the SQL. | N/A | N/A | |
String | Optional | If specified, adds a warning message for this macro. This is processed as an NCalc, and the warning message will ALWAYS be present and will be the value of the evaluated NCalc expression. | N/A | N/A |
Examples (1)
Example 1:
This example selects several columns from a database table:
[Database.Values: sql="SELECT top 1 Id, Name, Age FROM People", timeoutMs=30000] Id [String: value={Id}], Name [String: value={Name}], Age [String: value={Age}].