ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafyexpudf.htm

68 lines
4.5 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Use UDFs to query instances of UDTs" />
<meta name="abstract" content="Suppose you need to know how much e-mail was sent by a specific customer regarding customer orders and you have the e-mail address of your customers in the customers table." />
<meta name="description" content="Suppose you need to know how much e-mail was sent by a specific customer regarding customer orders and you have the e-mail address of your customers in the customers table." />
<meta name="DC.subject" content="UDTs (User-defined types), UDFs to query instances of UDTs example, examples, UDFs to query instances of UDTs, UDFs (User-defined functions), UDFs to query instances of UDTs example" />
<meta name="keywords" content="UDTs (User-defined types), UDFs to query instances of UDTs example, examples, UDFs to query instances of UDTs, UDFs (User-defined functions), UDFs to query instances of UDTs example" />
<meta name="DC.Relation" scheme="URI" content="rbafyexampcomplex.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafyexpudf" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Use UDFs to query instances of UDTs</title>
</head>
<body id="rbafyexpudf"><a name="rbafyexpudf"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Use UDFs to query instances of UDTs</h1>
<div><p>Suppose you need to know how much e-mail was sent by a specific
customer regarding customer orders and you have the e-mail address of your
customers in the customers table.</p>
<div class="section"><p>The statement is as follows:</p>
<pre> <strong>SELECT COUNT</strong> (*)
<strong>FROM</strong> ELECTRONIC_MAIL AS EMAIL, CUSTOMERS
<strong>WHERE</strong> SUBJECT (EMAIL.MESSAGE) = 'customer order'
<strong>AND</strong> CUSTOMERS.EMAIL_ADDRESS = SENDER (EMAIL.MESSAGE)
<strong>AND</strong> CUSTOMERS.NAME = 'Customer X'</pre>
</div>
<div class="section"><p>You have used the UDFs defined on the UDT in this SQL query since
they are the only means to manipulate the UDT. In this sense, your UDT e-mail
is completely encapsulated. Its internal representation and structure are
hidden and can only be manipulated by the defined UDFs. These UDFs know how
to interpret the data without the need to expose its representation.</p>
</div>
<div class="section"><p>Suppose you need to know the details of all the e-mail your company
received in 1994 that had to do with the performance of your products in the
marketplace.</p>
<pre> <strong>SELECT</strong> SENDER (MESSAGE), SENDING_DATE (MESSAGE), SUBJECT (MESSAGE)
<strong>FROM</strong> ELECTRONIC_MAIL
<strong>WHERE</strong> CONTAINS (MESSAGE,
'"performance" <strong>AND</strong> "products" <strong>AND</strong> "marketplace"') = 1 </pre>
</div>
<div class="section"><p>You have used the <samp class="codeph">contains</samp> UDF that is capable
of analyzing the contents of the message searching for relevant keywords or
synonyms.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyexampcomplex.htm" title="The following examples show how you can use user-defined types (UDTs), user-defined functions (UDFs), and large objects (LOBs) together in complex applications.">Examples of using UDTs, UDFs, and LOBs</a></div>
</div>
</div>
</body>
</html>