# Adding a Constraint With Multiple Conditions

In Creating a Conditional Constraint Using the Constraints Tab, a constraint was added to the join that specifies if the widgetId of the availRequest element is equal to the widgetId of the priceRequest element the merged repeating element quoteResponse be returned. Creating a constraint using the Where Clause Expression pane of the Constraints tab adds a where clause to the XQuery for loops which limits the target repeating elements which are returned during run time. During run time, the for loop will iterate only over those repeating elements that meet the complex condition.. In this section you add another condition (resulting in a complex condition) to the where of the for loop to further limit what is returned by the for loop as shown in the figure.

Figure : Complex Constraint

To Add a Condition to the Join in the Data Transformation Tutorial

1. From the BEA WebLogic Workshop menu bar, choose File —> New —> Application....

The New Application dialog box is displayed.

2. In the left pane, select the Tutorial folder.
3. In the right pane, select Tutorial: Process Application.

4. In the Name field, enter Tutorial_Add_Condition.
5. From the Server drop-down menu, select the integration server. For example, if you installed WebLogic Platform in the c:\bea directory on Windows, the path to the integration server is:

    c:\bea\weblogic81\samples\domains\integration

6. Click Create.

Your Tutorial Process application is created and displayed in the Application tab.

7. In the Application tab, expand the Tutorial_Add_ConditionWeb folder.

The directories and files that make up the Tutorial project are displayed.

8. In the Application tab, expand the Tutorial_Add_ConditionWeb/requestquote folder.

The DTF, XQ, and JPD files used in the tutorial are displayed. These files are part of the Tutorial project.

9. View Join.xq in the Design View. In the Application tab, double-click Tutorial_Process_Application\Tutorial_Add_ConditionWeb\requestquote\TutorialJoin.dtf\Join.xq and select the Design View tab.
10. Select the link between the availQuoteDoc\availRequest node and the quote\quoteResponse node in the Target pane.

The single condition that makes up the where clause is displayed in Where Clause Expression pane of the Constraints tab.

11. Create the second condition in the where clause:

1. In the Source pane select the availQuoteDoc/availRequest/requestedQuanity node and drag-and-drop it into the Left Hand Expression section of the Where Clause Expression pane.
2. Select the < operator.
3. Remove the text in the Right Hand Expression section of the Where Clause Expression pane.
4. In the Right Hand Expression section of the Where Clause Expression pane enter 50.
5. From the Join Type field select the AND option.

The Join Type determines how the conditions that make up where clause are evaluated during run time.

6. Click Add.

The second condition is added to the where clause of the for loop.

12. To run the query, select the Test View of the XQ file.
13. In this step, you import AvailQuote.xml for the source parameter: $availQuoteDoc:

1. From the drop-down menu in the Source Data pane, select $availQuoteDoc.
2. Click Import... .

The Open XML File to Test dialog box is displayed.

3. Double-click the requestquote folder.
4. Double-click the testxml folder.
5. Double-click the AvailQuote.xml file.

14. In this step, you import PriceQuote.xml for the source parameter: $priceQuoteDoc:

1. From the drop-down menu in the Source Data pane, select $priceQuoteDoc.
2. Click Import... .

The Open XML File to Test dialog box is displayed.

3. Double-click the requestquote folder.
4. Double-click the testxml folder.
5. Double-click the PriceQuote.xml file.

15. Enter the taxRate value:

1. From the drop-down menu in the Source Data pane, select $taxRate.
2. In the Node Value field of the $taxRate node, double-click on the existing value, and enter: 0.08 and click Enter.

16. In the Result Data pane, click Test.

If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.

In the Result Data pane, a graphical representation of the target data is displayed. The XML result for this example is also displayed in Figure: Complex Constraint.

During run time, the where clause limits what is returned by the for loop. If the two widgetIds are equal and the requestedQuanity is less than 50, the quoteResponse element is returned.