179 lines
11 KiB
HTML
179 lines
11 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="SET CONNECTION statement, SET CONNECTION,
|
|
SQL statements, changing with SET CONNECTION, connection, trigger, procedures,
|
|
in SET CONNECTION statement, server-name, variable" />
|
|
<title>SET CONNECTION</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="etconj"></a>
|
|
<h2 id="etconj"><a href="rbafzmst02.htm#ToC_1276">SET CONNECTION</a></h2><a id="idx3117" name="idx3117"></a><a id="idx3118" name="idx3118"></a><a id="idx3119" name="idx3119"></a>
|
|
<a name="setconj"></a>
|
|
<p id="setconj">The SET CONNECTION statement establishes the current server
|
|
of the activation group by identifying one of its existing connections.</p>
|
|
<a name="wq1733"></a>
|
|
<h3 id="wq1733"><a href="rbafzmst02.htm#ToC_1277">Invocation</a></h3>
|
|
<p>This statement can only be embedded within an application program or issued
|
|
interactively. It is an executable statement that cannot be dynamically prepared.
|
|
It must not be specified in Java™ or REXX.</p><a id="idx3120" name="idx3120"></a><a id="idx3121" name="idx3121"></a>
|
|
<p>SET CONNECTION is not allowed in a trigger. SET CONNECTION is not allowed
|
|
in an external procedure if the external procedure is called on a remote application server.</p>
|
|
<a name="wq1734"></a>
|
|
<h3 id="wq1734"><a href="rbafzmst02.htm#ToC_1278">Authorization</a></h3>
|
|
<p>None required.</p>
|
|
<a name="wq1735"></a>
|
|
<h3 id="wq1735"><a href="rbafzmst02.htm#ToC_1279">Syntax</a></h3>
|
|
<a href="rbafzmstetconj.htm#synssc"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
|
|
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn378.htm"
|
|
border="0" /></span><a href="#skipsyn-377"><img src="c.gif" alt="Skip visual syntax diagram"
|
|
border="0" /></a>>>-SET CONNECTION--+-<span class="italic">server-name</span>-+-----------------------------><
|
|
'-<span><span class="italic">variable</span></span>----'
|
|
|
|
</pre>
|
|
<a name="skipsyn-377" id="skipsyn-377"></a>
|
|
<a name="synssc"></a>
|
|
<h3 id="synssc"><a href="rbafzmst02.htm#ToC_1280">Description</a></h3>
|
|
<dl class="parml">
|
|
<dt class="bold"><var class="pv">server-name</var> <span class="base">or</span>
|
|
<span class="term"><var class="pv">variable</var></span></dt><a id="idx3122" name="idx3122"></a><a id="idx3123" name="idx3123"></a>
|
|
<dd>Identifies the connection by the specified server name or the server
|
|
name contained in the variable. If a variable is specified:
|
|
<ul>
|
|
<li>It must be a character-string variable with a length attribute that is
|
|
not greater than 18.</li>
|
|
<li>It must not be followed by an indicator variable.</li>
|
|
<li>The server name must be left-justified within the variable and must conform
|
|
to the rules for forming an ordinary identifier.</li>
|
|
<li>If the length of the server name is less than the length of the variable,
|
|
it must be padded on the right with blanks.</li></ul>
|
|
</dd>
|
|
</dl>
|
|
<p>Let S denote the specified server name or the server name contained in
|
|
the variable. S must identify an existing connection of the application process.
|
|
If S identifies the current connection, the state of S and all other connections
|
|
of the application process are unchanged, but information about S is placed
|
|
in the SQLERRP field of the SQLCA. The following rules apply when S identifies
|
|
a dormant connection.</p>
|
|
<p>If the SET CONNECTION statement is successful: </p>
|
|
<ul>
|
|
<li>Connection S is placed in the current state.</li>
|
|
<li>S is placed in the CURRENT SERVER special register.</li>
|
|
<li>Information about the application server is placed in the <var class="pv">connection-information-items</var> in the SQL Diagnostics Area.</li>
|
|
<li>Information about application server S is also placed in the SQLERRP field of
|
|
the SQLCA. If the application server is an IBM® relational database product, the information
|
|
has the form <var class="pv">pppvvrrm</var>, where:
|
|
<ul>
|
|
<li><var class="pv">ppp</var> identifies the product as follows:
|
|
<ul class="simple">
|
|
<li>ARI for DB2® for VSE and VM</li>
|
|
<li>DSN for DB2 UDB for z/OS</li>
|
|
<li>QSQ for DB2 UDB for iSeries</li>
|
|
<li>SQL for all other DB2 products</li></ul></li>
|
|
<li><var class="pv">vv</var> is a two-digit version identifier such as '04'</li>
|
|
<li><var class="pv">rr</var> is a two-digit release identifier such as '01'</li>
|
|
<li><var class="pv">m</var> is a one-digit modification level such as '0'</li></ul>
|
|
<p>For example, if the application server is Version 4 of DB2 UDB for z/OS, the value
|
|
of SQLERRP is 'DSN04010'.</p></li>
|
|
<li>Additional information about the connection is available from the DB2_CONNECTION_STATUS
|
|
and DB2_CONNECTION_TYPE connection information items in the SQL Diagnostics
|
|
Area.
|
|
<p>The DB2_CONNECTION_STATUS connection information item indicates the
|
|
status of connection for this unit of work. It will have one of the following
|
|
values: </p>
|
|
<ul>
|
|
<li> 1 - Commitable updates can be performed on the connection for this unit
|
|
of work.</li>
|
|
<li> 2 - No commitable updates can be performed on the connection for this
|
|
unit of work.</li></ul>
|
|
<p>The DB2_CONNECTION_TYPE connection information item indicates
|
|
the type of connection. It will have one of the following values: </p>
|
|
<ul>
|
|
<li> 1 - Connection is to a local relational database.</li>
|
|
<li> 2 - Connection is to a remote relational database with the conversation
|
|
unprotected.</li>
|
|
<li> 3 - Connection is to a remote relational database with the conversation
|
|
protected.</li>
|
|
<li> 4 - Connection is to an application requester driver program.</li></ul></li>
|
|
<li>Additional information about the connection is also placed in the SQLERRD(4)
|
|
field of the SQLCA. SQLERRD(4) will contain a value indicating whether the application server allows
|
|
commitable updates to be performed. Following is a list of values and their
|
|
meanings for the SQLERRD(4) field of the SQLCA on the CONNECT :
|
|
<ul>
|
|
<li> 1 - Commitable updates can be performed and either the connection uses
|
|
an unprotected conversation, is a connection established to an application
|
|
requester driver program using a CONNECT (Type 1) statement, or is a local
|
|
connection established using a CONNECT (Type 1) statement.</li>
|
|
<li> 2 - No commitable updates can be performed; conversation is unprotected.</li>
|
|
<li> 3 - It is unknown if commitable updates can be performed; conversation
|
|
is protected.</li>
|
|
<li> 4 - It is unknown if commitable updates can be performed; conversation
|
|
is unprotected.</li>
|
|
<li> 5 - It is unknown if commitable updates can be performed and the connection
|
|
is either a local connection established using a CONNECT (Type 2) statement
|
|
or a connection to an application requester driver program established using
|
|
a CONNECT (Type 2) statement.</li></ul></li>
|
|
<li>Additional information about the connection is placed in the SQLERRMC
|
|
field of the SQLCA. Refer to Appendix B, "SQL Communication Area" for a description
|
|
of the information in the SQLERRMC field.</li>
|
|
<li>Any previously current connection is placed in the dormant state.</li></ul>
|
|
<p>If the SET CONNECTION statement is unsuccessful, the connection state of
|
|
the activation group and the states of its connections are unchanged.</p>
|
|
<a name="wq1736"></a>
|
|
<h3 id="wq1736"><a href="rbafzmst02.htm#ToC_1281">Notes</a></h3>
|
|
<p><span class="bold">SET CONNECTION for CONNECT (Type 1)</span>: The use of CONNECT
|
|
(Type 1) statements does not prevent the use of SET CONNECTION, but the statement
|
|
either fails or does nothing because dormant connections do not exist.</p>
|
|
<p><span class="bold">Status after connection is restored</span>: When a connection
|
|
is used, made dormant, and then restored to the current state in the same
|
|
unit of work, the status of locks, cursors, and prepared statements for that
|
|
connection reflects its last use by the activation group.</p>
|
|
<p><span class="bold">Local connections</span>: A SET CONNECTION to a local connection
|
|
will fail if the current independent auxiliary Storage pool (IASP) name space
|
|
does not match the local connection's relational database.</p>
|
|
<a name="wq1737"></a>
|
|
<h3 id="wq1737"><a href="rbafzmst02.htm#ToC_1282">Example</a></h3>
|
|
<p>Execute SQL statements at TOROLAB1, execute SQL statements at TOROLAB2,
|
|
and then execute more SQL statements at TOROLAB1. </p>
|
|
<div class="lines"> <tt class="xph">EXEC SQL <span class="bold">CONNECT TO</span> TOROLAB1; </tt><br />
|
|
<br />
|
|
(Execute statements referencing objects at TOROLAB1)<br />
|
|
<br />
|
|
<tt class="xph">EXEC SQL <span class="bold">CONNECT TO</span> TOROLAB2; </tt><br />
|
|
<br />
|
|
(Execute statements referencing objects at TOROLAB2)<br />
|
|
<br />
|
|
<tt class="xph">EXEC SQL <span class="bold">SET CONNECTION</span> TOROLAB1;</tt><br />
|
|
<br />
|
|
(Execute statements referencing objects at TOROLAB1)<br />
|
|
</div>
|
|
<p>The first CONNECT statement creates the TOROLAB1 connection, the second
|
|
CONNECT statement places it in the dormant state, and the SET CONNECTION statement
|
|
returns it to the current state. <a id="idx3124" name="idx3124"></a><a id="idx3125" name="idx3125"></a></p>
|
|
<hr /><br />
|
|
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmsthselin.htm">Previous Page</a> | <a href="rbafzmstsetdebug.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>
|