142 lines
8.0 KiB
HTML
142 lines
8.0 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 SCHEMA statement, SET SCHEMA, SQL statements,
|
|
SQL path, current path special register" />
|
|
<title>SET SCHEMA</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="setschema"></a>
|
|
<h2 id="setschema"><a href="rbafzmst02.htm#ToC_1334">SET SCHEMA</a></h2><a id="idx3202" name="idx3202"></a><a id="idx3203" name="idx3203"></a><a id="idx3204" name="idx3204"></a><a id="idx3205" name="idx3205"></a>
|
|
<p>The SET SCHEMA statement changes the value of the CURRENT SCHEMA special
|
|
register.</p>
|
|
<a name="wq1785"></a>
|
|
<h3 id="wq1785"><a href="rbafzmst02.htm#ToC_1335">Invocation</a></h3>
|
|
<p>This statement can be embedded in an application program or issued interactively.
|
|
It is an executable statement that can be dynamically prepared.</p>
|
|
<a name="wq1786"></a>
|
|
<h3 id="wq1786"><a href="rbafzmst02.htm#ToC_1336">Authorization</a></h3>
|
|
<p>No authorization is required to execute this statement.</p>
|
|
<a name="wq1787"></a>
|
|
<h3 id="wq1787"><a href="rbafzmst02.htm#ToC_1337">Syntax</a></h3>
|
|
<a href="rbafzmstsetschema.htm#synsss"><img src="c.gif" alt="Click to skip syntax diagram" /></a>
|
|
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn391.htm"
|
|
border="0" /></span><a href="#skipsyn-390"><img src="c.gif" alt="Skip visual syntax diagram"
|
|
border="0" /></a> .-CURRENT-. .-=-.
|
|
>>-SET--+-+---------+--SCHEMA-+--+---+-------------------------->
|
|
'-CURRENT_SCHEMA------'
|
|
|
|
>----+-<span class="italic">schema-name</span>------+--------------------------------------><
|
|
+-+-<span>SESSION_USER</span>-+-+
|
|
| '-<span>USER</span>---------' |
|
|
+-<span>SYSTEM_USER</span>------+
|
|
+-<span><span class="italic">variable</span></span>---------+
|
|
+-<span class="italic">string-constant</span>--+
|
|
'-DEFAULT----------'
|
|
|
|
</pre>
|
|
<a name="skipsyn-390" id="skipsyn-390"></a>
|
|
<a name="synsss"></a>
|
|
<h3 id="synsss"><a href="rbafzmst02.htm#ToC_1338">Description</a></h3>
|
|
<dl class="parml">
|
|
<dt class="bold"><var class="pv">schema-name</var></dt>
|
|
<dd>Identifies a schema. No validation that the schema exists is made at
|
|
the time the CURRENT SCHEMA is set.
|
|
<p>If the value specified does
|
|
not conform to the rules for a <var class="pv">schema-name</var>, an error is returned.</p>
|
|
</dd>
|
|
<dt class="bold">SESSION_USER or USER</dt>
|
|
<dd>This value is the SESSION_USER special register.
|
|
</dd>
|
|
<dt class="bold">SYSTEM_USER</dt>
|
|
<dd>This value is the SYSTEM_USER special register.
|
|
</dd>
|
|
<dt class="bold"><var class="pv">variable</var></dt>
|
|
<dd>Specifies a variable which contains a schema name. The content
|
|
is not folded to uppercase.
|
|
<p>The variable: </p>
|
|
<ul>
|
|
<li>Must be a character-string, UTF-16 graphic, or UCS-2 graphic variable.
|
|
The actual length of the contents of the <var class="pv">variable</var> must not exceed
|
|
the length of a schema name. See <a href="rbafzmstlimtabs.htm#limtabs">Appendix A. SQL limits</a>.</li>
|
|
<li>Must not be followed by an indicator variable.</li>
|
|
<li>Must include a schema that is left justified and must conform to the rules
|
|
for forming an ordinary or delimited identifier.</li>
|
|
<li>Must be padded on the right with blanks if the variable is fixed length.</li>
|
|
<li>Must not be the null value.</li>
|
|
<li>Must not be the keyword SESSION_USER, SYSTEM_USER, or USER.</li></ul>
|
|
</dd>
|
|
<dt class="bold"><var class="pv">string-constant</var></dt>
|
|
<dd>A character or UCS-2 constant with a schema name.
|
|
</dd>
|
|
<dt class="bold">DEFAULT</dt>
|
|
<dd>The CURRENT SCHEMA is set to its initial value. The initial value for
|
|
SQL naming is USER. The initial value for system naming is *LIBL.
|
|
</dd>
|
|
</dl>
|
|
<a name="wq1788"></a>
|
|
<h3 id="wq1788"><a href="rbafzmst02.htm#ToC_1339">Notes</a></h3>
|
|
<p><span class="bold">Considerations for keywords:</span> There is
|
|
a difference between specifying a single keyword (such as USER) as a single
|
|
keyword or as a delimited identifier. To indicate that the current value of
|
|
the USER special register should be used for setting the current schema, specify
|
|
USER as a keyword. If USER is specified as a delimited identifier instead
|
|
(for example, "USER"), it is interpreted as a schema name of that value ("USER").</p>
|
|
<p><span class="bold">Transaction considerations:</span> The SET SCHEMA statement
|
|
is not a commitable operation. ROLLBACK has no effect on the CURRENT SCHEMA.</p>
|
|
<p><span class="bold">Impact on other special registers:</span> Setting
|
|
the CURRENT SCHEMA special register does not effect the CURRENT PATH special
|
|
register. Hence, the CURRENT SCHEMA will not be included in the SQL path and
|
|
functions, procedures and user-defined type resolution may not find these
|
|
objects. To include the current schema value in the SQL path, whenever the
|
|
SET SCHEMA statement is issued, also issue the SET PATH statement including
|
|
the schema name from the SET SCHEMA statement.</p>
|
|
<p><span class="bold">CURRENT SCHEMA:</span> The value of the CURRENT SCHEMA special
|
|
register is used as the qualifier for all unqualified names in all dynamic
|
|
SQL statements except in programs where the DYNDFTCOL has been specified.
|
|
If DYNDFTCOL is specified in a program, its schema name is used instead of
|
|
the CURRENT SCHEMA schema name.</p>
|
|
<p>For SQL naming, the initial value of the CURRENT SCHEMA special register
|
|
is equivalent to USER. For system naming, the initial value of the CURRENT
|
|
SCHEMA special register is '*LIBL'.</p>
|
|
<p><span class="bold">Syntax alternatives:</span> CURRENT SQLID is accepted as
|
|
a synonym for CURRENT SCHEMA and the effect of a SET CURRENT SQLID statement
|
|
will be identical to that of a SET CURRENT SCHEMA statement. No other effects,
|
|
such as statement authorization changes, will occur.</p>
|
|
<p>SET SCHEMA is equivalent to calling the QSQCHGDC API.</p>
|
|
<a name="wq1789"></a>
|
|
<h3 id="wq1789"><a href="rbafzmst02.htm#ToC_1340">Examples</a></h3>
|
|
<p><span class="italic">Example 1:</span> The following statement sets the CURRENT
|
|
SCHEMA special register.</p>
|
|
<pre class="xmp"> <span class="bold">SET SCHEMA =</span> RICK </pre>
|
|
<p><span class="italic">Example 2:</span> The following example retrieves the
|
|
current value of the CURRENT SCHEMA special register into the host variable
|
|
called CURSCHEMA.</p>
|
|
<pre class="xmp"> EXEC SQL <span class="bold">VALUES(CURRENT SCHEMA) INTO</span> :CURSCHEMA </pre><p class="indatacontent">The value would be RICK, set by the previous example.</p>
|
|
<hr /><br />
|
|
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmsthsetrs.htm">Previous Page</a> | <a href="rbafzsetsessionauth.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>
|