ibm-information-center/dist/eclipse/plugins/i5OS.ic.ddp_5.4.0.1/rbal1bind.htm

101 lines
6.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="Bind an application" />
<meta name="abstract" content="Before you can run your application program, a relationship between the program and any referred-to tables and views must be established. This process is called binding." />
<meta name="description" content="Before you can run your application program, a relationship between the program and any referred-to tables and views must be established. This process is called binding." />
<meta name="DC.subject" content="application program, binding, binding an application, access plan, definition, SQL package, SQL package" />
<meta name="keywords" content="application program, binding, binding an application, access plan, definition, SQL package, SQL package" />
<meta name="DC.Relation" scheme="URI" content="rbal1pdrdp.htm" />
<meta name="DC.Relation" scheme="URI" content="rbal1packcreation.htm" />
<meta name="DC.Relation" scheme="URI" content="../cl/crtsqlpkg.htm" />
<meta name="DC.Relation" scheme="URI" content="rbal1wrkpkg.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="rbal1bind" />
<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>Bind an application</title>
</head>
<body id="rbal1bind"><a name="rbal1bind"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Bind an application</h1>
<div><p>Before you can run your application program, a relationship between
the program and any referred-to tables and views must be established. This
process is called <dfn class="term">binding</dfn>.</p>
<div class="section"><p>The result of binding is an access plan. The <dfn class="term">access plan</dfn> is
a control structure that describes the actions necessary to satisfy each SQL
request. An access plan contains information about the program and about the
data the program intends to use. For distributed relational database work,
the access plan is stored in the SQL package and managed by the server along
with the SQL package.</p>
</div>
<div class="section"><p>SQL automatically attempts to bind and create access plans when
the result of a successful compile is a program or service program object.
If the compile is not successful or the result of a compile is a module object,
access plans are not created. If, at run time, the database manager detects
that an access plan is not valid or that changes have occurred to the database
that might improve performance (for example, the addition of indexes), a new
access plan is automatically created. If the application server (AS) is not
an <span class="keyword">iSeries™ server</span>, then a bind must
be done again using the <span class="cmdname">Create Structured Query Language Package
(CRTSQLPKG)</span> command. binding does three things:</p>
<ul><li>Revalidates the SQL statements using the description in the
database. <p>During the bind process, the SQL statements are checked for
valid table, view, and column names. If a referred to table or view does not
exist at the time of the precompile or compile, the validation is done at
run time. If the table or view does not exist at run time, a negative SQLCODE
is returned.</p>
</li>
<li>Selects the access paths needed to access the data your program wants
to process. <p>In selecting an access path, indexes, table sizes, and other
factors are considered when SQL builds an access plan. The bind process considers
all indexes available to access the data and decides which ones (if any) to
use when selecting a path to the data.</p>
</li>
<li>Attempts to build access plans. <p>If all the SQL statements are valid,
the bind process builds and stores access plans in the program.</p>
</li>
</ul>
</div>
<div class="section"><p>If the characteristics of a table or view your program accesses
have changed, the access plan might no longer be valid. When you attempt to
use an access plan that is not valid, the server automatically attempts to
rebuild the access plan. If the access plan cannot be rebuilt, a negative
SQLCODE is returned. In this case, you might have to change the program's
SQL statements and reissue the CRTSQL<em>xxx</em> command to correct the situation.</p>
</div>
<div class="section"><p>For example, if a program contains an SQL statement that refers
to COLUMNA in TABLEA and the user deletes and recreates TABLEA so that COLUMNA
no longer exists, when you call the program, the automatic rebind is unsuccessful
because COLUMNA no longer exists. You must change the program source and reissue
the CRTSQL<em>xxx</em> command.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbal1pdrdp.htm" title="When you write a program using SQL, you can embed the SQL statements in a host program.">Prepare distributed relational database programs</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rbal1wrkpkg.htm" title="An SQL package is an SQL object used specifically by distributed relational database applications. It contains control structures for each SQL statement that accesses data on an application server (AS).">Work with SQL packages</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="rbal1packcreation.htm" title="An object called an SQL package can be created as part of the precompile process when the CRTSQLxxx command is compiled.">SQL package creation</a></div>
<div><a href="../cl/crtsqlpkg.htm">Create Structured Query Language Package (CRTSQLPKG) command</a></div>
</div>
</div>
</body>
</html>