16.10.2015 Views

Getting Started with IBM Data Studio for DB2

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

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

Chapter 9– Developing user-defined functions 277<br />

5. To run the UDF again, follow the steps highlighted in Section 9.4. However, since the<br />

updated UDF expects an input parameter, you must specify that parameter. The Run<br />

and Per<strong>for</strong>mance Options tab opens in the UDF editor view, where you can specify<br />

whether to commit the changes to the database.<br />

6. Specify the input parameter value, as shown in Figure 9.13, then click OK to run the<br />

UDF.<br />

Figure 9.13 – Specify a value <strong>for</strong> the input parameter of the UDF<br />

7. As explained in Section 9.5, the status of running the UDF, and any returned value can<br />

be observed in SQL Results view. In this case, the returned value will be a scalar<br />

integer value which is the number of tables inGOSALESCT schema that starts <strong>with</strong> the<br />

phraseCUST.<br />

9.7 Summary<br />

In this chapter, you learned the value of using user-defined functions to improve<br />

per<strong>for</strong>mance of SQL access by being able to process a set of SQL on the database server<br />

rather than sending each request over the wire separately. In addition, by encapsulating<br />

the database logic, those UDFs can be called and used by multiple applications. UDFs also<br />

provide a way to extend the SQL language <strong>with</strong> your own functions. You also learned the<br />

most important steps in the creation and maintenance of user-defined functions using <strong>Data</strong><br />

<strong>Studio</strong>.<br />

9.8 Exercise<br />

As an exercise <strong>for</strong> this chapter, create a table UDF that returns the name and schema of all<br />

functions that have the qualifier equal to the value passed as a parameter to the function.

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

Saved successfully!

Ooh no, something went wrong!