Specifying a value for the Query Text property
The Query Text property on the Property Binding page of the data set editor is the same as the queryText property in the report source file. The value you specify on the Property Binding page updates the queryText property in the source file, and must use the same format you see in the report source file. In addition, you must enclose the value you type in double quotation marks (" ").
The following example shows the correct syntax for specifying a Query Text value for a JDBC data set:
"select CUSTOMERNAME, CUSTOMERNUMBER from CUSTOMERS where COUNTRY = 'Australia'"
The following example shows the correct syntax for specifying a Query Text value for a flat file data set:
"select Date, Open, High from StockHistory.csv"
The previous examples showed the syntax for a Query Text value, but both examples specified static data. Typically, when you specify a value for the Query Text property, you use variables or JavaScript expressions that evaluate to a specific value at run time.
The following example shows how to select a text file at run time. The JavaScript expression params["pTextFileName"] refers to a report parameter whose value evaluates to a file name specified at run time.
"select PRODUCTNAME, QUANTITYINSTOCK, MSRP from " + params["pTextFileName"]
The following example shows how to select from a database the customer rows for a particular country. The country value is specified by the user at run time through the report parameter p_Country.
"select CUSTOMERNAME, CUSTOMERNUMBER, COUNTRY from CUSTOMERS where COUNTRY = " + "'" + params["p_Country"] + "'"