Parameterize the query of a database node in Clementine.

Alex van Buitenen, dec 2008

The sample below uses a stream parameter to fill the query of a database node.

The sample assumes you have a datasource called "Test", that contains a table called "Table1" that contains a Field called "Field1".
Click here to download the sample stream.

To reproduce this sample follow these steps:

Add a database node and a table node to a Clementine stream.
Call the database node "QueryWithParam".
Doubleclick "QueryWithParam".
Select "SQL Query".
Set the Datasource to "Test".
Enter the Query: "select P1 from Table1".
P1 is the field we want to parameterize.

Fig. 1. The properties of the database node.

Add a parameter to the stream: Right click the stream canvas and select "Stream Properties".

Fig. 2. The database- and table node on the canvas, then selecting "Stream Properties".

Press the "Parameters" tab of the stream, and add the parameter to the stream.

Fig. 3. Adding a parameter to the stream.

Press the "Script" tab of the stream, and enter the expression:

set QueryWithParam.query = "select " >< '$P-Param1' >< " from Table1"

(QueryWithParam is the name of the database node)
('$P-Param1' is used to insert Param1 in Clementine)
(The "><" is the concatenation symbol in Clementine).

Fig. 4. Defining the stream script.

Execute the stream by choosing Tools,Execute:


 

Fig. 5. Executing the stream.

Doubleclick the database node "QueryWithParam" once again, and notice that the old Query
"Select P1 from Table1"
has been replaced by
"Select Field1 from Table1".

Fig. 6. The database node with the new Query.