Skip to main content

SQL Variable

Description

Stores the result of a database query into a variable


Parameters

Name
Required
Default Value
Description

Name

Yes


Variable name

Data Source

Yes


Data source to query

Injected

Yes

false

If set to true, the body will have any '%prefix:keychain%' values injected with values from the current report item prior to being evaluated.

Data Type

Yes


Table

Allows setting the data type of the variable to facilitate access later on. The type can be:

  • Table - keeps the result as a table
  • Row - if only one row is desired, unwraps that row object. If multiple rows are returned from the query, only the first row is kept
  • Scalar - if only a single value is desired, extracts it based on its data type. If multiple rows or columns are returned, only keeps the first row and column.

Examples

Read a row to a variable and report on it

CODE
{sql-variable:ds=myDB|injected=true|name=user|type=Row}
select *
from user
where username = '%page:title%'
{sql-variable}
 
 
{report-on:injected=true}
Name: %variable:user > row:name%
Email: %variable:user > row:email%
Phone: %variable:user > row:phone%
{report-on}


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.