29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The form and the JSPs are now ready to be run on a server, but before you do<br />

that you will need to do one more thing. You will need to give the server the<br />

information it needs to connect to the database.<br />

Update the search argument<br />

One thing we want to do is to update the condition on the SQL statement in<br />

SearchItemMasterView.jsp to make sure that if the search argument appears in<br />

the item’s long description that we get a match. Currently, we use the “Like”<br />

argument. As coded, we will only get a match if the user input matches the long<br />

description exactly.<br />

The current code looks like:<br />

<br />

<br />

<br />

SELECT<br />

DB2ADMIN.ITEM.ITEM_NUMBER,<br />

DB2ADMIN.ITEM.ITEM_SHORT_DESC,<br />

DB2ADMIN.ITEM.ITEM_LONG_DESC,<br />

DB2ADMIN.ITEM.QUANTITY,<br />

DB2ADMIN.ITEM.PRICE,<br />

DB2ADMIN.ITEM.SOTD_FLAG<br />

FROM<br />

DB2ADMIN.ITEM<br />

WHERE<br />

DB2ADMIN.ITEM.ITEM_LONG_DESC LIKE :item_desc<br />

ORDER BY<br />

PRICE ASC<br />

<br />

<br />

<br />

Update the code as marked below in bold print.<br />

<br />

<br />

<br />

SELECT<br />

DB2ADMIN.ITEM.ITEM_NUMBER,<br />

DB2ADMIN.ITEM.ITEM_SHORT_DESC,<br />

DB2ADMIN.ITEM.ITEM_LONG_DESC,<br />

DB2ADMIN.ITEM.QUANTITY,<br />

DB2ADMIN.ITEM.PRICE,<br />

DB2ADMIN.ITEM.SOTD_FLAG<br />

FROM<br />

DB2ADMIN.ITEM<br />

WHERE UPPER (DB2ADMIN.ITEM.ITEM_LONG_DESC ) LIKE :item_desc<br />

ORDER BY<br />

Chapter 6. Accessing databases 193

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

Saved successfully!

Ooh no, something went wrong!