87 lines
5.6 KiB
HTML
87 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 xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="dc.language" scheme="rfc1766" 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. -->
|
|
<meta name="dc.date" scheme="iso8601" content="2005-09-19" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<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="keywords" content="routine, function, procedures" />
|
|
<title>Routines</title>
|
|
<link rel="stylesheet" type="text/css" href="ibmidwb.css" />
|
|
<link rel="stylesheet" type="text/css" href="ic.css" />
|
|
</head>
|
|
<body>
|
|
<a id="Top_Of_Page" name="Top_Of_Page"></a><!-- Java sync-link -->
|
|
<script language = "Javascript" src = "../rzahg/synch.js" type="text/javascript"></script>
|
|
|
|
|
|
<a name="ch1routines"></a>
|
|
<h2 id="ch1routines"><a href="rbafzmst02.htm#ToC_39">Routines</a></h2><a id="idx108" name="idx108"></a>
|
|
<p>A <span class="italic">routine</span> is an executable SQL object. There are
|
|
two types of routines.</p>
|
|
<a name="wq15"></a>
|
|
<h3 id="wq15"><a href="rbafzmst02.htm#ToC_40">Functions</a></h3><a id="idx109" name="idx109"></a>
|
|
<p>A <span class="italic">function</span> is a routine that can be invoked from
|
|
within other SQL statements and returns a value or a table. For more information,
|
|
see <a href="rbafzmstch2function.htm#ch2function">Functions</a>.</p>
|
|
<p>Functions are classified as either SQL functions or external
|
|
functions. SQL functions are written using SQL statements, which are also
|
|
known collectively as SQL procedural language. External functions reference
|
|
a host language program which may or may not contain SQL statements.</p>
|
|
<p>A <span class="italic">function</span> is created with the CREATE FUNCTION
|
|
statement. For more information about creating functions, see <a href="rbafzmstcreatef.htm#createf">CREATE FUNCTION</a>.</p>
|
|
<a name="ch1proc"></a>
|
|
<h3 id="ch1proc"><a href="rbafzmst02.htm#ToC_41">Procedures</a></h3><a id="idx110" name="idx110"></a>
|
|
<p>A <span class="italic">procedure</span> (sometimes called a <span class="italic">stored procedure</span>) is a routine that can be called to perform operations
|
|
that can include both host language statements and SQL statements.</p>
|
|
<p>Procedures are classified as either SQL procedures or external
|
|
procedures. SQL procedures are written using SQL statements, which are also
|
|
known collectively as SQL procedural language. External procedures reference
|
|
a host language program which may or may not contain SQL statements.</p>
|
|
<p>Procedures in SQL provide the same benefits as procedures in a host language.
|
|
That is, a common piece of code need only be written and maintained once and
|
|
can be called from several programs. Both host languages and SQL can call
|
|
procedures that exist on the local system. However, SQL can also call a procedure
|
|
that exists on a remote system. In fact, the major benefit of procedures in
|
|
SQL is that they can be used to enhance the performance characteristics of
|
|
distributed applications.</p>
|
|
<p>Assume several SQL statements must be executed at a remote system. When
|
|
the first SQL statement is executed, the application requester will send a
|
|
request to an application server to perform the operation. It will then wait for a
|
|
reply that indicates whether the statement executed successfully or not and
|
|
optionally returns results. When the second and each subsequent SQL statement
|
|
is executed, the application requester will send another request and wait
|
|
for another reply.</p>
|
|
<p>If the same SQL statements are stored in a procedure at an application server,
|
|
a CALL statement can be executed that references the remote procedure. When
|
|
the CALL statement is executed, the application requester will send a single
|
|
request to the current server to call the procedure. It will then wait for
|
|
a single reply that indicates whether the procedure executed successfully
|
|
or not and optionally returns results.</p>
|
|
<p>The following two figures illustrate the way stored procedures can be used
|
|
in a distributed application to eliminate some of the remote requests. <a href="rbafzmstch1routines.htm#call01">Figure 1</a> shows a program making many remote requests.</p>
|
|
<a name="call01"></a>
|
|
<div class="fignone" id="call01"><span class="figcap">Figure 1. Application Without Remote Procedure</span>
|
|
<div class="mmobj">
|
|
<img src="rbal3505.gif" alt="Application without remote procedure" /></div></div>
|
|
<a name="call02"></a>
|
|
<div class="fignone" id="call02"><span class="figcap">Figure 2. Application With Remote Procedure</span>
|
|
<div class="mmobj">
|
|
<img src="rbal3506.gif" alt="Application with remote procedure" /></div></div>
|
|
<hr /><br />
|
|
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstpackageap.htm">Previous Page</a> | <a href="rbafzmstsequences.htm">Next Page</a> | <a href="rbafzmst02.htm#wq1">Contents</a> |
|
|
<a href="rbafzmstindex.htm#index">Index</a> ]
|
|
|
|
<a id="Bot_Of_Page" name="Bot_Of_Page"></a>
|
|
</body>
|
|
</html>
|