ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/rsltchng.htm

126 lines
8.2 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="Change ResultSets" />
<meta name="abstract" content="With the iSeries JDBC drivers, you can change ResultSets by performing several tasks." />
<meta name="description" content="With the iSeries JDBC drivers, you can change ResultSets by performing several tasks." />
<meta name="DC.Relation" scheme="URI" content="rsltsets.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltchar.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltcurs.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltdata.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltclse.htm" />
<meta name="DC.Relation" scheme="URI" content="resultex.htm" />
<meta name="DC.Relation" scheme="URI" content="usingpositioneddelete.htm" />
<meta name="DC.Relation" scheme="URI" content="usingpositionedupdate.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rsltchng" />
<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>Change ResultSets</title>
</head>
<body id="rsltchng"><a name="rsltchng"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Change ResultSets</h1>
<div><p>With the iSeries™ JDBC drivers, you can change ResultSets by
performing several tasks.</p>
<div class="section"><p>The default setting for ResultSets is read only. However, with Java™ Database
Connectivity (JDBC) 2.0, the iSeries JDBC drivers provide complete support for
updateable ResultSets.</p>
<p>You can refer to ResultSet <a href="rsltchar.htm">concurrency</a> on
how to update ResultSets.</p>
<p><strong>Update rows</strong></p>
<p>Rows may be updated
in a database table through the ResultSet interface. The steps involved in
this process are the following:</p>
</div>
<ol><li><span>Change the values for a specific row using various update&lt;<em>Type</em>&gt;
methods, where &lt;<em>Type</em>&gt; is a Java data type. These update&lt;<em>Type</em>&gt;
methods correspond to the get&lt;<em>Type</em>&gt; methods available for retrieving
values.</span></li>
<li><span>Apply the rows to the underlying database.</span></li>
</ol>
<div class="section"><p>The database itself is not updated until the second step. Updating
columns in a ResultSet without calling the updateRow method does not make
any changes to the database.</p>
<p>Planned updates to a row can be thrown
away with the cancelUpdates method. Once the updateRow method is called, changes
to the database are final and cannot be undone.</p>
<p><strong>Note:</strong> The rowUpdated
method always returns false as the database does not have a way to point out
which rows have been updated. Correspondingly, the updatesAreDetected method
returns false.</p>
<p><strong>Delete rows</strong></p>
<p>Rows may be deleted in a database
table through the ResultSet interface. The deleteRow method is provided and
deletes the current row.</p>
<p><strong>Insert rows</strong></p>
<p>Rows may be inserted
into a database table through the ResultSet interface. This process makes
use of an "insert row" which applications specifically move the cursor to
and build the values they want to insert into the database. The steps involved
in this process are as follows:</p>
<ol><li>Position the cursor on the insert row.</li>
<li>Set each of the values for the columns in the new row.</li>
<li>Insert the row into the database and optionally move the cursor back to
the current row within the ResultSet.</li>
</ol>
<div class="note"><span class="notetitle">Note:</span> New rows are not inserted into the table where the cursor is positioned.
They are typically added to the end of the table data space. A relational
database is not position-dependent by default. For example, you should not
expect to move the cursor to the third row and insert something that shows
up before the forth row when subsequent users fetch the data.</div>
<p><strong>Support
for positioned updates</strong></p>
<p>Besides the method for updating the database
through a ResultSet, SQL statements can be used to issue positioned updates.
This support relies on using named cursors. JDBC provides the setCursorName
method from Statement and the getCursorName method from ResultSet to provide
access to these values.</p>
<p>Two DatabaseMetaData methods, supportsPositionedUpdated
and supportsPositionedDelete, both return true as this feature is supported
with the native JDBC driver.</p>
<p>See <a href="usingpositionedupdate.htm">Example:
Change values with a statement through another statement's cursor</a> for
more information.</p>
<p>See <a href="usingpositioneddelete.htm">Example:
Remove values from a table through another statement's cursor</a> for more
information. </p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="usingpositioneddelete.htm">Example: Remove values from a table through another statement's cursor</a></strong><br />
This is an example of how to remove values from a table through another statement's cursor.</li>
<li class="ulchildlink"><strong><a href="usingpositionedupdate.htm">Example: Change values with a statement through another statement's cursor</a></strong><br />
This is an example of how to change values with a statement through another statement's cursor.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rsltsets.htm" title="The ResultSet interface provides access to the results generated by running queries. Conceptually, data of a ResultSet can be thought of as a table with a specific number of columns and a specific number of rows. By default, the table rows are retrieved in sequence. Within a row, column values can be accessed in any order.">ResultSets</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rsltchar.htm" title="This topic discusses ResultSet characteristics such ResultSet types, concurrency, ability to close the ResultSet by committing the connection object, and specification of ResultSet characteristics.">ResultSet characteristics</a></div>
<div><a href="rsltcurs.htm" title="The iSeries Java Database Connectivity (JDBC) drivers support scrollable ResultSets. With a scrollable ResultSet, you can process rows of data in any order using a number of cursor-positioning methods.">Cursor movement</a></div>
<div><a href="rsltdata.htm" title="The ResultSet object provides several methods for obtaining column data for a row. All are of the form get&lt;Type&gt;, where &lt;Type&gt; is a Java data type. Some examples of these methods include getInt, getLong, getString, getTimestamp, and getBlob. Nearly all of these methods take a single parameter that is either the column index within the ResultSet or the column name.">Retrieve ResultSet data</a></div>
<div><a href="rsltclse.htm" title="To create a ResultSet object, you can use executeQuery methods, or other methods. This article describes options for creating ResultSets.">Create ResultSets</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="resultex.htm" title="This is an example of how to use the ResultSet interface.">Example: ResultSet interface for IBM Developer Kit for Java</a></div>
</div>
</div>
</body>
</html>