Scenario: Executing a stored procedure in the MDM Hub - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

The following job is intended for calculating the total price of each kind of products recorded on your MDM Web UI.

This Job will generate parameters used to execute a stored procedure in the MDM Hub, then extract the desired data from the returned XML-format result and present the extracted data in the studio.

The products of which the prices are to be treated are listed on your MDM Web UI.

This Job requires you to have previously created a stored procedure called PriceAddition in the MDM Repository tree view and deployed this stored procedure to the server. The procedure uses the following steps:

for $d in distinct-values(//Product/Name)
let $product := //Product[Name= $d and Price >= %0 and Price <=%1]
order by $d
return <result><Name>{$d}</Name><Sum>{sum($product/Price)}</Sum></result>

For more information on working with stored procedures, see Talend Studio User Guide.

To create this Job, proceed as follows:

  1. Drag and drop the following components used in this example: tFixedFlowInput, tMDMSP, tExtractXMLField, tLogRow.

  2. Connect the components using the Row Main link.

  3. The tFixedFlowInput is used to generate the price range of your interest for this calculation. In this example, define 10 as the minimum and 17 as the maximum in order to cover all of the products. To begin, double-click on tFixedFlowInput to open its Component view.

  4. On the Component view, click the [...] button next to Edit schema to open the schema editor of this component.

  5. In the schema editor, add the two parameters min and max that are used to define the price range.

  6. Click OK.

    In the Values table, in the Mode area of the Component view, the two parameters min and max that you have defined in the schema editor of this component display.

  7. In the Value column of the Values table, enter 10 for the min parameter and 17 for the max parameter.

  8. Double-click on tMDMSP to open its Component view.

  9. In the URL field of the Component view, type in the MDM server address, in this example, http://localhost:8180/talendmdm/services/soap.

  10. In the Password field, enter the authentication information.

  11. In Data Container and Procedure Name, enter the exact names of the data container Product and of the stored procedure PriceAddition.

  12. Under the Parameters table, click the plus button two times to add two rows in this table.

  13. In the Parameters table, click each of both rows you have added and from the drop-down list, select the min parameter for one and the max parameter for the other.

  14. Double-click on tExtractXMLField to open its Component view.

  15. On the Component view, click the [...] button next to Edit schema to open the schema editor of this component.

  16. In the schema editor, add two columns to define the structure of the outcoming data. These two columns are name and sum. They represent respectively the name and the total price of each kind of product recorded in the MDM Web UI.

  17. Click OK to validate the configuration and the two columns display in the Mapping table of the Component view.

  18. In the Loop XPath query field, type in the node of the XML tree, which the loop is based on. In this example, the node is /result as you can read in the procedure code: return <result><Name>{$d}</Name><Sum>{sum($product/Price)}</Sum></result>.

  19. In XPath query of the Mapping table, enter the exact node name on which the loop is applied. They are /result/Name used to extract the product names and /result/Sum used to extract the total prices.

  20. Eventually, double-click tLogRow to open its Component view.

  21. Synchronize the schema with the preceding component.

  22. And select the Print values in cells of a table check box for reading convenience.

  23. Then press F6 to execute the Job.

  24. See the outcoming data in the console of the Run view.

The output lists the four kinds of products recorded in the MDM Web UI and the total price for each of them.