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

82 lines
5.6 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="Use qualified function reference" />
<meta name="abstract" content="If you use a qualified function reference, you restrict the search for a matching function to that schema." />
<meta name="description" content="If you use a qualified function reference, you restrict the search for a matching function to that schema." />
<meta name="DC.subject" content="UDFs (User-defined functions), calling, qualified function reference, examples, using qualified function reference" />
<meta name="keywords" content="UDFs (User-defined functions), calling, qualified function reference, examples, using qualified function reference" />
<meta name="DC.Relation" scheme="URI" content="rbafyudfuudf.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyuseunqualified.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafydefudt.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="rbafyusquref" />
<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>Use qualified function reference </title>
</head>
<body id="rbafyusquref"><a name="rbafyusquref"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use qualified function reference </h1>
<div><p>If you use a qualified function reference, you restrict the search
for a matching function to that schema.</p>
<div class="section"><p>For example, you have the following statement:</p>
<pre> <strong>SELECT</strong> PABLO.BLOOP(COLUMN1) <strong>FROM</strong> T </pre>
</div>
<div class="section"><p>Only the BLOOP functions in schema PABLO are considered. It does
not matter that user SERGE has defined a BLOOP function, or whether there
is a built-in BLOOP function. Now suppose that user PABLO has defined two
BLOOP functions in his schema:</p>
<pre> <strong>CREATE FUNCTION</strong> BLOOP (<strong>INTEGER</strong>) <strong>RETURNS</strong> ...
<strong>CREATE FUNCTION</strong> BLOOP (<strong>DOUBLE</strong>) <strong>RETURNS</strong> ...</pre>
</div>
<div class="section"><p>BLOOP is thus overloaded within the PABLO schema, and the function
selection algorithm chooses the best BLOOP, depending on the data type of
the argument, COLUMN1. In this case, both of the PABLO.BLOOPs take numeric
arguments, and if COLUMN1 is not one of the numeric types, the statement
will fail. On the other hand if COLUMN1 is either SMALLINT or INTEGER, function
selection will resolve to the first BLOOP, while if COLUMN1 is DECIMAL or
DOUBLE, the second BLOOP will be chosen. </p>
</div>
<div class="section"><p>Several points about this example:</p>
</div>
<div class="section"> <ol><li>It illustrates argument promotion. The first BLOOP is defined with an
INTEGER parameter, yet you can pass it a SMALLINT argument. The function
selection algorithm supports promotions among the built-in data types and DB2<sup>®</sup> performs
the appropriate data value conversions.</li>
<li>If for some reason you want to call the second BLOOP with a SMALLINT
or INTEGER argument, you need to take an explicit action in your statement
as follows: <pre> <strong>SELECT</strong> PABLO.BLOOP(<strong>DOUBLE</strong>(COLUMN1)) <strong>FROM</strong> T</pre>
</li>
<li>If you want to call the first BLOOP with a DECIMAL or DOUBLE argument,
you have your choice of explicit actions, depending on your intent: <pre> <strong>SELECT</strong> PABLO.BLOOP(<strong>INTEGER</strong>(COLUMN1)) <strong>FROM</strong> T
<strong>SELECT</strong> PABLO.BLOOP(<strong>FLOOR</strong>(COLUMN1)) <strong>FROM</strong> T </pre>
</li>
</ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyudfuudf.htm" title="Scalar and column UDFs can be called within an SQL statement almost everywhere that an expression is valid. Table UDFs can be called in the FROM clause of a SELECT. There are a few restrictions of UDF usage, however.">Use UDFs in SQL statements</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="rbafyuseunqualified.htm" title="You can use an unqualified function reference instead of a qualified function reference. In this case, DB2's search for a matching function normally uses the function path to qualify the reference.">Use unqualified function reference</a></div>
<div><a href="rbafydefudt.htm" title="UDTs are defined with a CREATE DISTINCT TYPE statement.">Define a UDT</a></div>
</div>
</div>
</body>
</html>