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

123 lines
7.7 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="Parameter style GENERAL WITH NULLS" />
<meta name="abstract" content="The parameter style GENERAL WITH NULLS can only be used with scalar UDFs." />
<meta name="description" content="The parameter style GENERAL WITH NULLS can only be used with scalar UDFs." />
<meta name="DC.subject" content="UDFs (User-defined functions), parameter style GENERAL WITH NULLS, passing SQL-argument, passing SQL-argument-ind-array, UDFs (User-defined functions), passing SQL-result-ind, DFT_SQLMATHWARN configuration parameter, passing SQL-result, RETURNS TABLE clause, CAST FROM clause" />
<meta name="keywords" content="UDFs (User-defined functions), parameter style GENERAL WITH NULLS, passing SQL-argument, passing SQL-argument-ind-array, UDFs (User-defined functions), passing SQL-result-ind, DFT_SQLMATHWARN configuration parameter, passing SQL-result, RETURNS TABLE clause, CAST FROM clause" />
<meta name="DC.Relation" scheme="URI" content="rbafypassarguments.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="rbafyparamgennull" />
<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>Parameter style GENERAL WITH NULLS</title>
</head>
<body id="rbafyparamgennull"><a name="rbafyparamgennull"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Parameter style GENERAL WITH NULLS</h1>
<div><p>The parameter style GENERAL WITH NULLS can only be used with scalar
UDFs.</p>
<div class="section"><p>With this parameter style, the parameters are passed into the
service program as follows (in the order specified):</p>
</div>
<div class="section"> <pre><span><img src="./c.gif" border="0" alt="Read syntax diagram" longdesc="rbafyparamgennullsyn1.htm" /></span><a href="#d0e48"><img src="./c.gif" border="0" alt="Skip visual syntax diagram" /></a>
    .------------------.   
    V |   
>>-SQL-result = funcname--(----+--------------+-+--------------->
    '-<i>SQL-argument</i>-'    
>--+------------------------+--<i>SQL-result-ind</i>--)--------------->&lt;
   '-<i>SQL-argument-ind-array</i>-'    
</pre><a name="d0e48"></a></div>
<div class="section"> <dl><dt class="dlterm"><em>SQL-argument</em></dt>
<dd>This argument is set by DB2<sup>®</sup> before calling the UDF. This value repeats <em>n</em> times,
where <em>n</em> is the number of arguments specified in the function reference.
The value of each of these arguments is taken from the expression specified
in the function invocation. It is expressed in the data type of the defined
parameter in the CREATE FUNCTION statement. Note: These parameters are treated
as input only; any changes to the parameter values made by the UDF are ignored
by DB2.</dd>
<dt class="dlterm"><em>SQL-argument-ind-array</em></dt>
<dd>This argument is set by DB2 before calling the UDF. It can be used by the UDF
to determine if one or more <em>SQL-arguments</em> are null or not. It is an
array of two-byte signed integers (indicators). The <em>n</em>th array argument
corresponds corresponds to the <em>n</em>th <em>SQL-argument</em>. Each array
entry is set to one of the following values: <dl><dt class="dlterm">0</dt>
<dd>The argument is present and not null. </dd>
<dt class="dlterm">-1</dt>
<dd>The argument is null.</dd>
</dl>
<p>The UDF should check for null input. Note: This parameter
is treated as input only; any changes to the parameter value made by the UDF
is ignored by DB2.</p>
</dd>
<dt class="dlterm"><em>SQL-result-ind</em></dt>
<dd>This argument is set by the UDF before returning to DB2. The database
provides the storage for the return value. The argument is defined as a two-byte
signed integer. If set to a negative value, the database interprets the result
of the function as null. If set to zero or a positive value, the database
uses the value returned in <em>SQL-result</em>. The database provides the storage
for the return value indicator. Since the parameter is passed by address,
the address is of the storage where the indicator value should be placed.</dd>
<dt class="dlterm"><em>SQL-result</em></dt>
<dd>This value is returned by the UDF. DB2 copies the value into database storage.
In order to return the value correctly, the function code must be a value-returning
function. The database copies only as much of the value as defined for the
return value as specified on the CREATE FUNCTION statement. If the CAST FROM
clause is used in the CREATE FUNCTION statement, DB2 assumes the UDF returns the value as
defined in the CAST FROM clause, otherwise DB2 assumes the UDF returns the value as
defined in the RETURNS clause. <p>Because of the requirement that the function
code be a value-returning function, any function code used for parameter style
GENERAL WITH NULLS must be created into a service program.</p>
<div class="note"><span class="notetitle">Notes:</span> <ol><li>The external name specified on the CREATE FUNCTION statement can be specified
either with or without single quotation marks. If the name is not quoted,
it is uppercased before it is stored; if it is quoted, it is
stored as specified. This becomes important when naming the actual program,
as the database searches for the program that has a name that exactly matches
the name stored with the function definition. For example, if a function was
created as: <pre> <strong>CREATE FUNCTION</strong> X(INT) <strong>RETURNS</strong> INT
<strong>LANGUAGE</strong> C
<strong>EXTERNAL NAME</strong> 'MYLIB/MYPGM(MYENTRY)'
</pre>
and the source for the program was: <pre> void myentry(
int*in
int*out,
.
.
. .</pre>
the database will not find the entry because it is
in lowercase <em>myentry</em> and the database was instructed to look for uppercase <em>MYENTRY</em>.</li>
<li>For service programs with C++ modules, make sure in the C++ source code
to precede the program function definition with <em>extern "C"</em>. Otherwise,
the C++ compiler will perform 'name mangling' of the function's name and the
database will not find it.</li>
</ol>
</div>
</dd>
</dl>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafypassarguments.htm" title="DB2 provides storage for all parameters passed to a UDF. Therefore, parameters are passed to the external function by address.">Pass arguments from DB2 to external functions</a></div>
</div>
</div>
</body>
</html>