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

145 lines
7.9 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="task" />
<meta name="DC.Title" content="Query a database using Interactive SQL" />
<meta name="abstract" content="Using the SQL SELECT statement and Interactive SQL, you can query a database on another iSeries server for data you need to create or update a table on the local server." />
<meta name="description" content="Using the SQL SELECT statement and Interactive SQL, you can query a database on another iSeries server for data you need to create or update a table on the local server." />
<meta name="DC.subject" content="moving data, using interactive SQL, interactive SQL, moving data between servers" />
<meta name="keywords" content="moving data, using interactive SQL, interactive SQL, moving data between servers" />
<meta name="DC.Relation" scheme="URI" content="rbal1mvdat.htm" />
<meta name="DC.Relation" scheme="URI" content="../sqlp/rbafykickoff.htm" />
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmst02.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="rbal1queryint" />
<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>Query a database using Interactive SQL</title>
</head>
<body id="rbal1queryint"><a name="rbal1queryint"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Query a database using Interactive SQL</h1>
<div><p>Using the SQL SELECT statement and Interactive SQL, you can query
a database on another <span class="keyword">iSeries™ server</span> for
data you need to create or update a table on the local server. </p>
<div class="section"> <p>The SELECT statement allows you to specify the table name and
columns containing the desired data, and selection criteria or filters that
determine which rows of data are retrieved. If the SELECT statement is successful,
the result is one or more rows of the specified table.</p>
<p>In addition to
getting data from one table, SQL allows you to get information from columns
contained in two or more tables in the same database by using a join operation.
If the SELECT statement is successful, the result is one or more rows of the
specified tables. The data values in the columns of the rows returned represent
a composite of the data values contained in specified tables.</p>
<p>Using
an Interactive SQL query, the results of a query can be placed in a database
file on the local server. If a commitment control level is specified for the
Interactive SQL process, it applies to the application server (AS); the database
file on the local server is under a commitment control level of *NONE.</p>
<p>Interactive
SQL allows you to do the following things: </p>
<ul><li>Create a new file for the results of a select.</li>
<li>Replace an existing file.</li>
<li>Create a new member in a file.</li>
<li>Replace a member.</li>
<li>Append the results to an existing member.</li>
</ul>
<p>Consider the situation in which the KC105 dealership is transferring
its entire stock of part number 1234567 to KC110. KC110 queries the KC105
database for the part they acquire from KC105. The result of this inventory
query is returned to a database file that already exists on the KC110 server.
This is the process you can use to complete this task:</p>
<p>Use the <span class="cmdname">Start
SQL (STRSQL)</span> command to get the Interactive SQL display. Before
you enter any SQL statement (other than a CONNECT) for the new database, specify
that the results of this operation are sent to a database file on the local
server by doing the following steps: </p>
</div>
<ol><li class="stepexpand"><span>Select the Services option from the Enter SQL Statements
display.</span></li>
<li class="stepexpand"><span>Select the Change Session Attributes option from the Services display.</span></li>
<li class="stepexpand"><span>Enter the Select Output Device option from the Session Attributes
Display.</span></li>
<li class="stepexpand"><span>Type a 3 for a database file in the Output device field and press
Enter. The following display is shown: </span> <pre class="screen">Change File
Type choices, press Enter.
File . . . . . . . . . QSQLSELECT Name
Library . . . . . . QGPL Name
Member . . . . . . . . *FILE Name, *FILE, *FIRST
Option . . . . . . . . 1 1=Create new file
2=Replace file
3=Create new member
4=Replace member
5=Add to member
For a new file:
Authority . . . . . *LIBCRTAUT *LIBCRTAUT, *CHANGE, *ALL
*EXCLUDE, *USE
authorization list name
Text . . . . . . . .
F3=Exit F5=Refresh F12=Cancel
</pre>
</li>
<li class="stepexpand"><span>Specify the name of the database file that is to receive the results.</span></li>
</ol>
<div class="section"> <p>When the database name is specified, you can begin your Interactive
SQL processing as shown in the following example. </p>
<pre class="screen">Enter SQL Statements
Type SQL statement, press Enter.
Current connection is to relational database KC000.
CONNECT TO KC105__________________________________________________________
Current connection is to relational database KC105.
====&gt; SELECT * FROM INVENTORY_____________________________________________
WHERE PART = '1234567'____________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
__________________________________________________________________________
Bottom
F3=Exit F4=Prompt F6=Insert line F9=Retrieve F10=Copy line
F12=Cancel F13=Services F24=More keys
</pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbal1mvdat.htm" title="A number of situations occur in enterprise operations that might require moving data from one iSeries server to another.">Move data from one iSeries server to another</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="../sqlp/rbafykickoff.htm">SQL programming</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="../db2/rbafzmst02.htm">SQL reference</a></div>
</div>
</div>
</body>
</html>