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

146 lines
9.4 KiB
HTML
Raw Permalink 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 SQL" />
<meta name="abstract" content="The parameter style SQL conforms to the industry standard Structured Query Language (SQL). This parameter style can only be used with scalar UDFs." />
<meta name="description" content="The parameter style SQL conforms to the industry standard Structured Query Language (SQL). This parameter style can only be used with scalar UDFs." />
<meta name="DC.subject" content="UDFs (User-defined functions), parameter style SQL, passing SQL-argument, passing SQL-result, RETURNS TABLE clause, CAST FROM clause, passing SQL-argument-ind, passing SQL-result-ind, passing SQL-state, passing function-name, passing specific-name, passing diagnostic-message" />
<meta name="keywords" content="UDFs (User-defined functions), parameter style SQL, passing SQL-argument, passing SQL-result, RETURNS TABLE clause, CAST FROM clause, passing SQL-argument-ind, passing SQL-result-ind, passing SQL-state, passing function-name, passing specific-name, passing diagnostic-message" />
<meta name="DC.Relation" scheme="URI" content="rbafypassarguments.htm" />
<meta name="DC.Relation" scheme="URI" content="../rzala/rzalakickoff.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="rbafyparamsql" />
<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 SQL</title>
</head>
<body id="rbafyparamsql"><a name="rbafyparamsql"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Parameter style SQL</h1>
<div><p>The parameter style SQL conforms to the industry standard Structured
Query Language (SQL). This parameter style can only be used with scalar UDFs.</p>
<div class="section"><p>With parameter style SQL, the parameters are passed into the external
program as follows (in the order specified): </p>
<div class="fignone"><div class="p"> <pre><span><img src="./c.gif" border="0" alt="Read syntax diagram" longdesc="rbafyparamsqlsyn1.htm" /></span><a href="#d0e66"><img src="./c.gif" border="0" alt="Skip visual syntax diagram" /></a>
>>-+------------------+--<i>SQL-result</i>--+----------------------+--->
   | .--------------. | | .------------------. |   
   | V | | | V | |   
   '---<i>SQL-argument</i>-+-' '---<i>SQL-argument-ind</i>-+-'   
>--<i>SQL-result-ind</i>--<i>SQL-state</i>--<i>function-name</i>--<i>specific-name</i>------>
>--<i>diagnostic-message</i>------------------------------------------>&lt;
</pre><a name="d0e66"></a></div>
</div>
</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-result</em></dt>
<dd>This argument is set by the UDF before returning to DB2. The database
provides the storage for the return value. Since the parameter is passed by
address, the address is of the storage where the return value should be placed.
The database provides as much storage as needed for the return value as defined
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.</dd>
<dt class="dlterm"><em>SQL-argument-ind</em></dt>
<dd>This argument is set by DB2 before calling the UDF. It can be used by the UDF
to determine if the corresponding <em>SQL-argument</em> is null or not. The
<em>n</em>th <em>SQL-argument-ind</em> corresponds to the <em>n</em>th <em>SQL-argument</em>,
described previously. Each indicator is defined as a two-byte signed integer.
It 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>If the function is defined with RETURNS NULL ON NULL INPUT,
the UDF does not need to check for a null value. However, if it is defined
with CALLS ON NULL INPUT, any argument can be NULL and the UDF should check
for null input. Note: these parameters are treated as input only; any changes
to the parameter values made by the UDF are 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-state</em></dt>
<dd>This argument is a CHAR(5) value that represents the SQLSTATE. <p>This
parameter is passed in from the database set to '00000' and can be set by
the function as a result state for the function. While normally the SQLSTATE
is not set by the function, it can be used to signal an error or warning to
the database as follows:</p>
<dl><dt class="dlterm"><em>01Hxx</em></dt>
<dd>The function code detected a warning situation. This results in an SQL
warning, Here <em>xx</em> may be one of several possible strings.</dd>
<dt class="dlterm"><em>38xxx</em></dt>
<dd>The function code detected an error situation. It results in a SQL error.
Here <em>xxx</em> may be one of several possible strings.</dd>
</dl>
</dd>
<dt class="dlterm"><em>function-name</em> </dt>
<dd>This argument is set by DB2 before calling the UDF. It is a VARCHAR(139) value
that contains the name of the function on whose behalf the function code is
being called. <p>The form of the function name that is passed is:</p>
<pre> &lt;<span class="synph"><span class="var">schema-name</span></span>&gt;.&lt;<span class="synph"><span class="var">function-name</span></span>&gt;</pre>
<p>This parameter is useful when
the function code is being used by multiple UDF definitions so that the code
can distinguish which definition is being called. Note: This parameter is
treated as input only; any changes to the parameter value made by the UDF
are ignored by DB2.</p>
</dd>
<dt class="dlterm"><em>specific-name</em></dt>
<dd>This argument is set by DB2 before calling the UDF. It is a VARCHAR(128) value
that contains the specific name of the function on whose behalf the function
code is being called. <p>Like function-name, this parameter is useful when
the function code is being used by multiple UDF definitions so that the code
can distinguish which definition is being called.
Note: This parameter is treated as input only; any changes to the parameter
value made by the UDF are ignored by DB2.</p>
</dd>
<dt class="dlterm"><em>diagnostic-message</em></dt>
<dd>This argument is set by DB2 before calling the UDF. It is a VARCHAR(70) value
that can be used by the UDF to send message text back when an SQLSTATE warning
or error is signaled by the UDF. <p>It is initialized by the database on
input to the UDF and may be set by the UDF with descriptive information. Message
text is ignored by DB2 unless the SQL-state parameter is set by the UDF.</p>
</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 class="relinfo"><strong>Related information</strong><br />
<div><a href="../rzala/rzalakickoff.htm">SQL messages and codes</a></div>
</div>
</div>
</body>
</html>