ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajp_5.4.0.1/rzajpbind.htm

87 lines
6.3 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?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="concept" />
<meta name="DC.Title" content="Bind an application that uses SQL" />
<meta name="abstract" content="Before you can run your application program, a relationship between the program and any specified tables and views must be established. This process is called binding. The result of binding is an access plan." />
<meta name="description" content="Before you can run your application program, a relationship between the program and any specified tables and views must be established. This process is called binding. The result of binding is an access plan." />
<meta name="DC.subject" content="binding, application, definitions, access plan, application plans" />
<meta name="keywords" content="binding, application, definitions, access plan, application plans" />
<meta name="DC.Relation" scheme="URI" content="rzajppreprog.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajppgmref.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="rzajpbind" />
<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 that uses SQL</title>
</head>
<body id="rzajpbind"><a name="rzajpbind"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Bind an application that uses SQL</h1>
<div><p>Before you can run your application program, a relationship between
the program and any specified tables and views must be established. This process
is called <em>binding</em>. The result of binding is an <em>access plan</em>.</p>
<p>The access plan 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.</p>
<p>For a nondistributed SQL program, the access plan is stored in the program.
For a distributed SQL program (where the RDB parameter was specified on the <span class="cmdname">CRTSQLxxx</span> command),
the access plan is stored in the SQL package at the specified relational database.</p>
<p>SQL automatically attempts to bind and create access plans when the program
object is created. For non-ILE compiles, this occurs as the result of a successful <span class="cmdname">CRTxxxPGM</span>.
For ILE compiles, this occurs as the result of a successful <span class="cmdname">CRTBNDxxx</span>, <span class="cmdname">CRTPGM</span>,
or <span class="cmdname">CRTSRVPGM</span> command. If <span class="keyword">DB2<sup>®</sup> UDB for iSeries™</span> detects
at run time that an access plan is not valid (for example, the referenced
tables are in a different library) or detects that changes have occurred to
the database that may improve performance (for example, the addition of indexes),
a new access plan is automatically created. Binding does three things: </p>
<ol><li><strong>It revalidates the SQL statements using the description in the database.</strong> During
the bind process, the SQL statements are checked for valid table, view, and
column names. If a specified 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.</li>
<li><strong>It selects the index needed to access the data your program wants to
process.</strong> In selecting an index, table sizes, and other factors are considered,
when it builds an access plan. It considers all indexes available to access
the data and decides which ones (if any) to use when selecting a path to the
data.</li>
<li><strong>It attempts to build access plans.</strong> If all the SQL statements are
valid, the bind process then builds and stores access plans in the program.</li>
</ol>
<p>If the characteristics of a table or view your program accesses have changed,
the access plan may no longer be valid. When you attempt to run a program
that contains an access plan that is not valid, the system 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 CRTSQLxxx command to correct the situation.</p>
<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 will be unsuccessful
because COLUMNA no longer exists. In this case you must change
the program source and reissue the <span class="cmdname">CRTSQLxxx</span> command.</p>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajppgmref.htm">Program references in applications that use SQL</a></strong><br />
All schemas, tables, views, SQL packages, and indexes referenced in SQL statements in an SQL program are placed in the object information repository (OIR) of the library when the program is created.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajppreprog.htm" title="This topic describes some of the tasks for preparing and running an application program.">Prepare and run a program with SQL statements</a></div>
</div>
</div>
</body>
</html>