ibm-information-center/dist/eclipse/plugins/i5OS.ic.db2_5.4.0.1/rbafzmstspecreg.htm

342 lines
22 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="special register, CURRENT DATE special register,
CURRENT_DATE special register, CURRENT DATE, CURRENT_DATE,
CURRENT DEBUG MODE special register, CURRENT DEBUG MODE,
CURRENT DEGREE special register, CURRENT DEGREE, CURRENT PATH special register,
CURRENT_PATH special register, CURRENT PATH, CURRENT_PATH,
CURRENT SCHEMA special register, CURRENT_SCHEMA special register, CURRENT SCHEMA,
CURRENT SERVER special register, CURRENT_SERVER special register, CURRENT SERVER,
CURRENT_SERVER, CURRENT TIME, CURRENT_TIME, CURRENT TIME special register,
CURRENT_TIME special register, CURRENT TIMESTAMP special register,
CURRENT_TIMESTAMP special register, CURRENT TIMESTAMP, CURRENT_TIMESTAMP,
CURRENT TIMEZONE special register, CURRENT_TIMEZONE special register,
CURRENT TIMEZONE, CURRENT_TIMEZONE, SESSION_USER special register, SESSION_USER,
SYSTEM_USER special register, SYSTEM_USER, USER special register, USER" />
<title>Special registers</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="specreg"></a>
<h2 id="specreg"><a href="rbafzmst02.htm#ToC_202">Special registers</a></h2><a id="idx538" name="idx538"></a>
<p>A <span class="italic">special register</span> is a storage area that is defined
for an application process by the database manager and is used to store information that
can be referenced in SQL statements. A reference to a special register is
a reference to a value provided by the current server. If the value is a string,
its CCSID is a default CCSID of the current server. The special registers
can be referenced as follows:</p>
<pre class="cgraphic"><span><img src="c.gif" alt="Read syntax diagram" longdesc="rbafzmstsyn13.htm"
border="0" /></span><a href="#skipsyn-12"><img src="c.gif" alt="Skip visual syntax diagram"
border="0" /></a>>>-+-+-CURRENT DATE------+------+------------------------------>&lt;
| | (1) | |
| '-CURRENT_DATE------' |
+---<span>CURRENT DEBUG MODE</span>-------+
+---<span>CURRENT DEGREE</span>-----------+
+-+-CURRENT PATH----------+--+
| +-CURRENT FUNCTION PATH-+ |
| | (1) | |
| '-CURRENT_PATH----------' |
+-+-CURRENT SCHEMA-+---------+
| '-CURRENT_SCHEMA-' |
+-+-CURRENT SERVER-+---------+
| '-CURRENT_SERVER-' |
+-+-CURRENT TIME------+------+
| | (1) | |
| '-CURRENT_TIME------' |
+-+-CURRENT TIMESTAMP------+-+
| | (1) | |
| '-CURRENT_TIMESTAMP------' |
+-+-CURRENT TIMEZONE-+-------+
| '-CURRENT_TIMEZONE-' |
+-+-<span>SESSION_USER</span>-+-----------+
| '-<span>USER</span>---------' |
'---<span>SYSTEM_USER</span>--------------'
</pre>
<a name="skipsyn-12" id="skipsyn-12"></a>
<a name="wq289"></a>
<div class="notelisttitle" id="wq289">Notes:</div>
<ol type="1">
<li>The SQL 2003 Core standard uses the form with the underscore.</li>
</ol>
<a name="c2curdt"></a>
<h3 id="c2curdt"><a href="rbafzmst02.htm#ToC_203">CURRENT DATE</a></h3><a id="idx539" name="idx539"></a><a id="idx540" name="idx540"></a><a id="idx541" name="idx541"></a><a id="idx542" name="idx542"></a>
<p>The CURRENT DATE special register specifies a date that is based on a reading
of the time-of-day clock when the SQL statement is executed at the current
server. If this special register is used more than once within a single SQL
statement, or used with CURRENT TIME, CURRENT TIMESTAMP, or the CURDATE, CURTIME,
or NOW scalar functions within a single statement; all values are based on
a single clock reading.<sup class="fn"><a id="wq291" name="wq291" href="rbafzmstspecreg.htm#wq292">26</a></sup></p>
<a name="wq293"></a>
<h4 id="wq293">Example</h4>
<p>Using the PROJECT table, set the project end date (PRENDATE) of the MA2111
project (PROJNO) to the current date. </p>
<pre class="xmp"> <span class="bold">UPDATE</span> PROJECT
&nbsp;&nbsp;<span class="bold">SET</span> PRENDATE = <span class="bold">CURRENT DATE</span>
&nbsp;&nbsp;<span class="bold">WHERE</span> PROJNO = 'MA2111'</pre>
<a name="c2curdbg"></a>
<h3 id="c2curdbg"><a href="rbafzmst02.htm#ToC_205">CURRENT DEBUG MODE</a></h3><a id="idx543" name="idx543"></a><a id="idx544" name="idx544"></a>
<p>The CURRENT DEBUG MODE special register specifies whether SQL
or Java procedures should be created or altered so they can be debugged by
the Unified Debugger. Any explicit specification of the DEBUG MODE or the DBGVIEW
option in the SET OPTION statement on the CREATE PROCEDURE or ALTER PROCEDURE
statement overrides the value in the CURRENT DEBUG MODE special register.
CURRENT DEBUG MODE affects static and dynamic SQL statements. The data type
of the register is VARCHAR(8). The valid values include:</p>
<dl class="parml">
<dt class="bold">DISALLOW</dt>
<dd>Procedures will be created so they cannot be debugged by the Unified Debugger.
When the DEBUG MODE attribute of a procedure is DISALLOW, the procedure can
be subsequently altered to change the DEBUG MODE attribute.
</dd>
<dt class="bold">ALLOW</dt>
<dd>Procedures will be created so they can be debugged by the Unified Debugger.
When the DEBUG MODE attribute of a procedure is DISALLOW, the procedure can
be subsequently altered to change the DEBUG MODE attribute.
</dd>
<dt class="bold">DISABLE</dt>
<dd>Procedures will be created so they cannot be debugged by the Unified Debugger.
When the DEBUG MODE attribute of a procedure is DISABLE, the procedure cannot
be subsequently altered to change the DEBUG MODE attribute.
</dd>
</dl>
<p>The value can be changed by invoking the SET CURRENT DEBUG MODE statement.
For details about this statement, see <a href="rbafzmstsetdebug.htm#setdebug">SET CURRENT DEBUG MODE</a>.</p>
<p>The initial value of CURRENT DEBUG MODE is DISALLOW.</p>
<a name="wq294"></a>
<h4 id="wq294">Example</h4>
<p>The following statement prevents subsequent creates or alters
of SQL or Java procedures from being debuggable:</p>
<pre class="xmp"> <span class="bold">SET CURRENT DEBUG MODE = DISALLOW</span></pre>
<a name="c2curdg"></a>
<h3 id="c2curdg"><a href="rbafzmst02.htm#ToC_207">CURRENT DEGREE</a></h3><a id="idx545" name="idx545"></a><a id="idx546" name="idx546"></a>
<p>The CURRENT DEGREE special register specifies the degree of I/O or Symmetric
MultiProcessing (SMP) parallelism for the execution of queries, index creates,
index rebuilds, index maintenance, and reorganizes. CURRENT DEGREE affects
static and dynamic SQL statements. The data type of the register is CHAR(5).
The valid values include:</p>
<dl class="parml">
<dt class="bold">1</dt>
<dd>No parallel processing is allowed.
</dd>
<dt class="bold">2 through 32767</dt>
<dd>Specifies the degree of parallelism that will be used.
</dd>
<dt class="bold">ANY</dt>
<dd>Specifies that the database manager can choose to use any number of tasks for either
I/O or SMP parallel processing.
<p>Use of parallel processing and the number
of tasks used is determined based on the number of processors available in
the system, this job's share of the amount of active memory available in the
pool in which the job is run, and whether the expected elapsed time for the
operation is limited by CPU processing or I/O resources. The database manager chooses
an implementation that minimizes elapsed time based on the job's share of
the memory in the pool.</p>
</dd>
<dt class="bold">NONE</dt>
<dd>No parallel processing is allowed.
</dd>
<dt class="bold">MAX</dt>
<dd>The database manager can choose to use any number of tasks for either I/O or SMP
parallel processing. MAX is similar to ANY except the database manager assumes that all
active memory in the pool can be used.
</dd>
<dt class="bold">IO</dt>
<dd>Any number of tasks can be used when the database manager chooses to use I/O parallel
processing for queries. SMP is not allowed.
</dd>
</dl>
<p>The value can be changed by invoking the SET CURRENT DEGREE statement.
For details about this statement, see <a href="rbafzsetdegree.htm#setdegree">SET CURRENT DEGREE</a>.</p>
<p>The initial value of CURRENT DEGREE is determined by the current degree
in effect from the CHGQRYA CL command, PARALLEL_DEGREE parameter in the current
query options file (QAQQINI), or the QQRYDEGREE system value.</p>
<a name="wq295"></a>
<h4 id="wq295">Example</h4>
<p>The following statement inhibits parallelism:</p>
<pre class="xmp"> <span class="bold">SET CURRENT DEGREE</span> = '1'</pre>
<a name="curpath"></a>
<h3 id="curpath"><a href="rbafzmst02.htm#ToC_209">CURRENT PATH</a></h3><a id="idx547" name="idx547"></a><a id="idx548" name="idx548"></a><a id="idx549" name="idx549"></a><a id="idx550" name="idx550"></a>
<p>The CURRENT PATH special register specifies the SQL path used to resolve
unqualified distinct type names, function names, and procedure names in dynamically
prepared SQL statements. It is also used to resolve unqualified procedure
names that are specified as variables in SQL CALL statements (CALL <span class="italic">variable</span>). The data type is VARCHAR(3483).</p>
<p>The CURRENT PATH special register contains the value of the SQL path which
is a list of one or more schema names, where each schema name is enclosed
in delimiters and separated from the following schema by a comma. The delimiters
and commas are included in the length of the special register. The maximum
number of schema names in the path is 268.</p>
<p>For information on when the SQL path is used to resolve unqualified names
in both dynamic and static SQL statements and the effect of its value, see <a href="rbafzmstch2nam.htm#qualun2">Unqualified function, procedure, specific, and distinct type names</a>.</p>
<p>The initial value of the CURRENT PATH special register in an activation
group is established by the first SQL statement that is executed. </p>
<ul>
<li>If the first SQL statement in an activation group is executed from an
SQL program or SQL package and the SQLPATH parameter was specified on the
CRTSQLxxx command, the path is the value specified in the SQLPATH parameter.
The SQLPATH value can also be specified using the SET OPTION statement.</li>
<li>Otherwise,
<ul>
<li>For SQL naming, "QSYS", "QSYS2", "<span class="italic">the value of the
authorization ID of the statement</span>" .</li>
<li>For system naming, "*LIBL".</li></ul></li></ul>
<p>The value of the special register can be changed by executing the SET PATH
statement. For details about this statement, see <a href="rbafzmstsetpath.htm#setpath">SET PATH</a>. For
portability across the platforms, it is recommended that a SET PATH statement
be issued at the beginning of an application.</p>
<a name="wq296"></a>
<h4 id="wq296">Example</h4>
<p>Set the special register so that schema SMITH is searched before schemas
QSYS and QSYS2 (SYSTEM PATH). </p>
<pre class="xmp"> <span class="bold">SET CURRENT PATH</span> SMITH, <span class="bold">SYSTEM PATH</span></pre>
<a name="cursch"></a>
<h3 id="cursch"><a href="rbafzmst02.htm#ToC_211">CURRENT SCHEMA</a></h3><a id="idx551" name="idx551"></a><a id="idx552" name="idx552"></a><a id="idx553" name="idx553"></a>
<p>The CURRENT SCHEMA special register specifies a VARCHAR(128) value that
identifies the schema name used to qualify unqualified database object references
where applicable in dynamically prepared SQL statements.<sup class="fn"><a id="wq297" name="wq297" href="rbafzmstspecreg.htm#wq298">27</a></sup> CURRENT SCHEMA is not used to qualify names 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>The initial value of CURRENT SCHEMA is the authorization ID of the current
session user.</p>
<p>The DFTRDBCOL keyword controls the schema name used to qualify unqualified
database object references where applicable for static SQL statements.</p>
<a name="wq299"></a>
<h4 id="wq299">Example</h4>
<p>Set the schema for object qualification to 'D123'.</p>
<pre class="xmp"> <span class="bold">SET CURRENT SCHEMA</span> = 'D123'</pre>
<a name="cursrv"></a>
<h3 id="cursrv"><a href="rbafzmst02.htm#ToC_213">CURRENT SERVER</a></h3><a id="idx554" name="idx554"></a><a id="idx555" name="idx555"></a><a id="idx556" name="idx556"></a><a id="idx557" name="idx557"></a>
<p>The CURRENT SERVER special register specifies a VARCHAR(18) value that
identifies the current application server.</p>
<p>CURRENT SERVER can be changed by the CONNECT (Type 1), CONNECT (Type 2),
or SET CONNECTION statements, but only under certain conditions. See the description
in <a href="rbafzmstconj1.htm#conj1">CONNECT (Type 1)</a>, <a href="rbafzmstcon2t.htm#con2t">CONNECT (Type 2)</a>, and <a href="rbafzmstetconj.htm#etconj">SET CONNECTION</a>.</p>
<p>CURRENT SERVER cannot be specified unless the local relational database
is named by adding the entry to the relational database directory using the
ADDRDBDIRE or WRKRDBDIRE command.</p>
<a name="wq300"></a>
<h4 id="wq300">Example</h4>
<p>Set the host variable APPL_SERVE (VARCHAR(18)) to the name of the current
server. </p>
<pre class="xmp"> <span class="bold">SELECT CURRENT SERVER
&nbsp;&nbsp;INTO</span> :APPL_SERVE
&nbsp;&nbsp;<span class="bold">FROM</span> SYSDUMMY1</pre>
<a name="c2curtm"></a>
<h3 id="c2curtm"><a href="rbafzmst02.htm#ToC_215">CURRENT TIME</a></h3><a id="idx558" name="idx558"></a><a id="idx559" name="idx559"></a><a id="idx560" name="idx560"></a><a id="idx561" name="idx561"></a>
<p>The CURRENT TIME special register specifies a time that is based on a reading
of the time-of-day clock when the SQL statement is executed at the current
server. If this special register is used more than once within a single SQL
statement, or used with CURRENT DATE, CURRENT TIMESTAMP, or the CURDATE, CURTIME,
or NOW scalar functions within a single statement; all values are based on
a single clock reading.<sup class="fn"><a id="wq301" name="wq301" href="rbafzmstspecreg.htm#wq302">28</a></sup></p>
<a name="wq303"></a>
<h4 id="wq303">Example</h4>
<p>Using the CL_SCHED table, select all the classes (CLASS_CODE) that start
(STARTING) later today. Today's classes have a value of 3 in the DAY column. </p>
<pre class="xmp"> <span class="bold">SELECT</span> CLASS_CODE <span class="bold">FROM</span> CL_SCHED
&nbsp;&nbsp;<span class="bold">WHERE</span> STARTING > <span class="bold">CURRENT TIME AND</span> DAY = 3</pre>
<a name="c2curts"></a>
<h3 id="c2curts"><a href="rbafzmst02.htm#ToC_217">CURRENT TIMESTAMP</a></h3><a id="idx562" name="idx562"></a><a id="idx563" name="idx563"></a><a id="idx564" name="idx564"></a><a id="idx565" name="idx565"></a>
<p>The CURRENT TIMESTAMP special register specifies a timestamp that is based
on a reading of the time-of-day clock when the SQL statement is executed at
the current server. If this special register is used more than once within
a single SQL statement, or used with CURRENT DATE, CURRENT TIME, or the CURDATE,
CURTIME, or NOW scalar functions within a single statement; all values are
based on a single clock reading.<sup class="fn"><a id="wq304" name="wq304" href="rbafzmstspecreg.htm#wq305">29</a></sup></p>
<a name="wq306"></a>
<h4 id="wq306">Example</h4>
<p>Insert a row into the IN_TRAY sample table. The value of the RECEIVED column
should be a timestamp that indicates when the row was inserted. The values
for the other three columns come from the host variables SRC (CHAR(8)), SUB
(CHAR(64)), and TXT (VARCHAR(200)). </p>
<pre class="xmp"> <span class="bold">INSERT INTO</span> IN_TRAY
&nbsp;&nbsp;<span class="bold">VALUES (CURRENT TIMESTAMP</span>, :SRC, :SUB, :TXT<span class="bold">)</span></pre>
<a name="c2curtz"></a>
<h3 id="c2curtz"><a href="rbafzmst02.htm#ToC_219">CURRENT TIMEZONE</a></h3><a id="idx566" name="idx566"></a><a id="idx567" name="idx567"></a><a id="idx568" name="idx568"></a><a id="idx569" name="idx569"></a>
<p>The
CURRENT TIMEZONE special register specifies the difference between UTC <sup class="fn"><a href="rbafzmstspecreg.htm#fn15">30</a></sup> and local time at the current server. The difference is represented
by a time duration (a decimal number in which the first two digits are the
number of hours, the next two digits are the number of minutes, and the last
two digits are the number of seconds). The number of hours is between -24
and 24 exclusive. Subtracting CURRENT TIMEZONE from a local time converts
that local time to UTC.</p>
<a name="wq307"></a>
<h4 id="wq307">Example</h4>
<p>Using the IN_TRAY table, select all the rows from the table and adjust
the value to UTC. </p>
<pre class="xmp"> <span class="bold">SELECT</span> RECEIVED - <span class="bold">CURRENT TIMEZONE</span>, SOURCE,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SUBJECT, NOTE_TEXT <span class="bold">FROM</span> IN_TRAY</pre>
<a name="ch2sesuser"></a>
<h3 id="ch2sesuser"><a href="rbafzmst02.htm#ToC_221">SESSION_USER</a></h3><a id="idx570" name="idx570"></a><a id="idx571" name="idx571"></a>
<p>The SESSION_USER special register specifies the run-time authorization
ID at the current server. The data type of the special register is VARCHAR(128).</p>
<p>The initial value of SESSION_USER for a new connection is the same as the
value of the SYSTEM_USER special register. Its value can be changed by invoking
the SET SESSION AUTHORIZATION statement.</p>
<a name="wq308"></a>
<h4 id="wq308">Example</h4>
<p>Select all notes from the <tt class="xph">IN_TRAY</tt> table that the user placed
there himself. </p>
<pre class="xmp"> <span class="bold">SELECT * FROM</span> IN_TRAY
&nbsp;&nbsp;<span class="bold">WHERE</span> SOURCE = <span class="bold">SESSION_USER</span></pre>
<a name="ch2sysuser"></a>
<h3 id="ch2sysuser"><a href="rbafzmst02.htm#ToC_223">SYSTEM_USER</a></h3><a id="idx572" name="idx572"></a><a id="idx573" name="idx573"></a>
<p>The SYSTEM_USER special register specifies the authorization ID that connected
to the current server. The data type of the special register is VARCHAR(128).</p>
<a name="wq309"></a>
<h4 id="wq309">Example</h4>
<p>Select all notes from the <tt class="xph">IN_TRAY</tt> table that the user placed
there himself. </p>
<pre class="xmp"> <span class="bold">SELECT * FROM</span> IN_TRAY
&nbsp;&nbsp;<span class="bold">WHERE</span> SOURCE = <span class="bold">SYSTEM_USER</span></pre>
<a name="ch2user"></a>
<h3 id="ch2user"><a href="rbafzmst02.htm#ToC_225">USER</a></h3><a id="idx574" name="idx574"></a><a id="idx575" name="idx575"></a>
<p>The USER special register specifies the run-time authorization ID at the
current server. The data type of the special register is VARCHAR(18).</p>
<p>The initial value of USER for a new connection is the same as the value
of the SYSTEM_USER special register. Its value can be changed by invoking
the SET SESSION AUTHORIZATION statement.</p>
<a name="wq310"></a>
<h4 id="wq310">Example</h4>
<p>Select all notes from the <tt class="xph">IN_TRAY</tt> table that the user placed
there himself. </p>
<pre class="xmp"> <span class="bold">SELECT * FROM</span> IN_TRAY
&nbsp;&nbsp;<span class="bold">WHERE</span> SOURCE = <span class="bold">USER</span></pre>
<hr /><div class="fnnum"><a id="wq292" name="wq292" href="rbafzmstspecreg.htm#wq291">26</a>.</div>
<div class="fntext">LOCALDATE can be specified as a synonym for CURRENT_DATE.</div><div class="fnnum"><a id="wq298" name="wq298" href="rbafzmstspecreg.htm#wq297">27</a>.</div>
<div class="fntext">For compatibility
with DB2 UDB for z/OS, the special register CURRENT SQLID is treated as a synonym
for CURRENT SCHEMA.</div><div class="fnnum"><a id="wq302" name="wq302" href="rbafzmstspecreg.htm#wq301">28</a>.</div>
<div class="fntext">LOCALTIME and LOCALTIME(0) can be specified as
a synonyms for CURRENT_TIME.</div><div class="fnnum"><a id="wq305" name="wq305" href="rbafzmstspecreg.htm#wq304">29</a>.</div>
<div class="fntext">LOCALTIMESTAMP and LOCALTIMESTAMP(6) can
be specified as a synonym for CURRENT_TIMESTAMP.</div><div class="fnnum"><a id="fn15" name="fn15">30</a>.</div>
<div class="fntext">Coordinated Universal Time, formerly known as GMT.</div>
<br />
<hr /><br />
[ <a href="#Top_Of_Page">Top of Page</a> | <a href="rbafzmstch2cons.htm">Previous Page</a> | <a href="rbafzmstch2col.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>