17. System Commands for the Forms-based Tools : report Command—Run a Report : Passing Parameters on the Command Line : Prompted Runtime Variables as Parameters
 
Share this page                  
Prompted Runtime Variables as Parameters
You can use variables in your report specification that prompt the user for a value at runtime. For string or date values, the report specification must be coded to include quotes around the variable that are appropriate for the query language. If these quotes are included in the report specification, the user can enter the value, as is, without the surrounding quotes. For example, suppose the report specification contains either the following statements:
.declare clientname with prompt 'Enter client's name:'
.query select balance from receivables
      where name = '$clientname'
Or, these QUEL statements:
.declare clientname with prompt 'Enter client's name:'
.query
range of e is receivables
retrieve (e.balance)
      where e.name = "$clientname"
At runtime, the user can enter:
report accounting receivables
Report‑Writer displays the prompt:
Enter client's name:
The user can respond:
Enter client's name: Lakeside Inn
If the report specification omits the query language‑specific quotes around a string or date variable, the user must enter these quotes along with the value on the command line. For example, suppose the report specification contains the following where clause for an SQL or QUEL query:
where name = $clientname
The user must respond to the prompt:
Enter client's name: 'Lakeside Inn'
If the value is a delimited identifier or contains embedded quotes, the user must follow their query language's rules for dereferencing quotes within the string.