Rule Builder > Queries and Facilities > Query Examples > Parameter-based Query

Using Parameter objects, you can now add parameters to a query at execution time. This operation requires installation of the Facility Explorer plug-in.

Note that for simplicity, this example starts from the original repository.

To create a parameter-based query proceed as follows:

  1. Click Reopen Repository on the File menu to reload the repository and then open the Facility Explorer.
  2. Open the Query Editor and click the images/addquery_icona.png button in the Query Editor to add a new query. The query is added to the Facility Explorer as a package with a single rule query as shown in Figure 17.26.

  3. images/add_querypackage.png
  4. Figure 17.26    Query Package with Rule Query
  5. Rename the rule query package to, for example, "p query" either in the Property Sheet or in the Facility Explorer. Rename the rule query to something more meaningful, for example, Priority Parameter.
  6. Right-click the p query package and then click Add Parameter on the shortcut menu, as shown in Figure 17.27.
  7. You can also click Add Parameter on the Project menu.

  8. images/add_queryparameter.png
  9. Figure 17.27    Adding a Parameter
  10. In the Property Sheet pane set the parameter type to java.lang.String and its name to ThePriority as shown in Figure 17.28.

  11. images/parameter_properties.png
  12. Figure 17.28    Setting the Parameter Properties
  13. Now right-click the rule query to open the Facility Editor and write the following rule query (using the <select an item> token):
  14.        For each business rule
                Such that priority is ThePriority
           
           Do
                Insert as query result
    

Your rule query should look like Figure 17.29.

images/query_panel3.png

  • Figure 17.29    Parameter Query Example
    1. Click the Query Editor tab to open it and display a table containing all the parameter information of the current query. Set the value of ThePriority to "high" as shown in Figure 17.30.

    2. images/parameter_tableinfo.png
    3. Figure 17.30    Query Editor Displaying Parameter Information
    4. Click the images/executequery_icona.png button to execute the rule query. The results show four rules found, as shown in Figure 17.31.

    5. images/query_example1.png
    6. Figure 17.31    Parameter Query Results

    See Also

    Introduction to Ruleset Parameters


    Customer Support | Copyright © 1987-2004 ILOG S.A. All rights reserved. Legal terms. PREVIOUS   NEXT