16.10.2015 Views

Getting Started with IBM Data Studio for DB2

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 10 – Developing data web services 295<br />

AND IL.INVENTORY_MONTH=:MONTH<br />

AND PN.PRODUCT_LANGUAGE = 'EN'<br />

GROUP BY PN.PRODUCT_NAME, IL.INVENTORY_MONTH,<br />

PB.PRODUCT_BRAND_EN, PN.PRODUCT_NAME, PN.PRODUCT_DESCRIPTION<br />

ORDER BY NUMBERS_SHIPPED DESC FETCH FIRST 50 ROWS ONLY<br />

Listing 10.3 – SQL SELECT <strong>for</strong> the GetBestSellingProductsByMonth operation<br />

Note:<br />

You can define parameter markers in two ways – via the question mark notation (a = ?) or<br />

via a named marker using the colon (a = :) notation. For web services both<br />

notations work, but the named parameter markers are preferable since the names will be<br />

used <strong>for</strong> the input parameter names of the resulting web service operation. If question mark<br />

notation is used the parameter names are just a sequence of p1, p2, …, pN. We use the<br />

named parameter marker notation in our statement <strong>for</strong> this reason.<br />

RankEmployee<br />

This statement inserts a new ranking record <strong>for</strong> a given employee number and an<br />

English ranking value term into the RANKING_RESULTS table of the<br />

GOSALESHR schema and returns the new row. Create a new SQL script named<br />

RankEmployee, and add the statement text as shown in Listing 10.4.<br />

SELECT * FROM FINAL TABLE (<br />

INSERT INTO GOSALESHR.RANKING_RESULTS (<br />

RANKING_DATE, RANKING_YEAR, EMPLOYEE_CODE, RANKING_CODE)<br />

VALUES (CURRENT TIMESTAMP, YEAR(CURRENT TIMESTAMP),<br />

:EMPLOYEE_CODE,<br />

(SELECT RANKING_CODE FROM GOSALESHR.RANKING WHERE<br />

UPPER(RANKING_DESCRIPTION_EN) = UPPER(LTRIM(RTRIM(CAST(:RANKING AS<br />

VARCHAR(90))))))))<br />

Listing 10.4 – SQL INSERT <strong>for</strong> the RankEmpoyee operation<br />

10.6 Create a new web service in the <strong>Data</strong> Project Explorer<br />

At this point you should have all the pieces together to start creating your web service. The<br />

following steps show how to create the web service.<br />

1. If you’re not there already, switch to the <strong>Data</strong> perspective. Right-click on the Web<br />

Services folder in your data development project and select New Web Service… as

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!