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

84 lines
6.1 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="Register UDFs" />
<meta name="abstract" content="A UDF must be registered in the database before the function can be recognized and used by SQL." />
<meta name="description" content="A UDF must be registered in the database before the function can be recognized and used by SQL." />
<meta name="DC.subject" content="UDFs (User-defined functions), registering UDFs, examples of registering, CREATE FUNCTION statement, to register a UDF" />
<meta name="keywords" content="UDFs (User-defined functions), registering UDFs, examples of registering, CREATE FUNCTION statement, to register a UDF" />
<meta name="DC.Relation" scheme="URI" content="rbafywudfextern.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx1.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx2.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfxa.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx3.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx5.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx6.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfcfx7.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmstcreatef.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="rbafyudfdudf" />
<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>Register UDFs</title>
</head>
<body id="rbafyudfdudf"><a name="rbafyudfdudf"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Register UDFs</h1>
<div><p>A UDF must be registered in the database before the function can
be recognized and used by SQL.</p>
<div class="section"><p>The statement allows you to specify the language and name of the
program, along with options such as DETERMINISTIC, ALLOW PARALLEL, and RETURNS
NULL ON NULL INPUT. These options help to more specifically identify to the
database the intention of the function and how calls to the database can be
optimized.</p>
</div>
<div class="section"><p>You should register an external UDF after you have written and
completely tested the actual code. It is possible to define the UDF before
actually writing it. However, to avoid any problems with running your UDF,
you are encouraged to write and test it extensively before registering it.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbafyudfcfx1.htm">Example: Exponentiation</a></strong><br />
In this example, suppose you have written an external UDF to perform exponentiation of floating point values, and want to register it in the MATH schema.</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfx2.htm">Example: String search</a></strong><br />
Suppose you have written a UDF to look for the existence of a given short string, passed as an argument, within a given CLOB value that is also passed as an argument. The UDF returns the position of the string within the CLOB if it finds the string, or zero if it does not.</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfxa.htm">Example: BLOB string search</a></strong><br />
In this example, you want the FINDSTRING function to work on BLOBs as well as on CLOBs. To do this, you define another FINDSTRING taking BLOB as the first parameter:</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfx3.htm">Example: String search over UDT</a></strong><br />
Assume that you are satisfied with the FINDSTRING functions from the BLOB string search, but now you have defined a distinct type BOAT with source type BLOB.</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfx5.htm">Example: AVG over a UDT</a></strong><br />
This example implements the AVG column function over the CANADIAN_DOLLAR distinct type.</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfx6.htm">Example: Counting</a></strong><br />
Your simple counting function returns a <samp class="codeph">1</samp> the
first time and increments the result by one each time it is called. This function
takes no SQL arguments, and by definition it is a NOT DETERMINISTIC function
since its answer varies from call to call.</li>
<li class="ulchildlink"><strong><a href="rbafyudfcfx7.htm">Example: Table function returning document IDs</a></strong><br />
In this example, you have written a table function that returns a row consisting of a single document identifier column for each known document in your text management system that matches a given subject area (the first parameter) and contains the given string (second parameter).</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafywudfextern.htm" title="You can write the executable code of a UDF in a language other than SQL.">Write UDFs as external functions</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../db2/rbafzmstcreatef.htm">CREATE FUNCTION statement</a></div>
</div>
</div>
</body>
</html>