⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update_iterator.htm

📁 The goal of this library is to make ODBC recordsets look just like an STL container. As a user, you
💻 HTM
📖 第 1 页 / 共 2 页
字号:
	cout << exampleUpdater.GetLastCount()
	<< " rows updated!" << endl;

	<span class="codeComment">// now can perform other updates using the same updater object
	// make sure to put in your new values for both the data and parameter values
	// for the update
	// set data fields we want to update to their desired values
	// exampleStr to &quot;Second Update&quot; and exampleLong to 66</span>
	TIMESTAMP_STRUCT tomorrow = {2000, 9, 30, 0, 0,0, 0};
	updateMe = Example(2222, &quot;Second Update&quot;, 0.11111, 66, tomorrow);
	updateMe.exampleLong = 66;

	*exampleUpdater = updateMe;

	<span class="codeComment">// now set the parameters indicating which rows</span>
	we want the update applied
	exampleUpdater.Params().lowIntValue = 21;
	exampleUpdater.Params().highIntValue = 30;
	exampleUpdater.Params().strValue = &quot;To
	find&quot;;

	TIMESTAMP_STRUCT otherParamDate = {2001, 10, 31,0, 0, 0, 0};
	exampleUpdater.Params().dateValue = otherParamDate;

	<span class="codeComment">// execute the update</span>
	exampleUpdater++;

	cout &lt;&lt; exampleUpdater.GetLastCount() &lt;&lt; &quot; rows updated!&quot; &lt;&lt; endl;
}
</code></pre>
<h3>Template parameters</h3>

<table border="2">
    <tr>
        <th>Parameter </th>
        <th>Description </th>
        <th>Default </th>
    </tr>
    <tr>
        <td valign="top"><tt>DataObj</tt> </td>
        <td valign="top">The type of object that will be updated
        in the <font size="2" face="Courier New">DBView</font>.
        This object will be bound through use of the <a
        href="BCA.htm"><font size="1" face="Courier New">BCA</font></a><font
        size="2"> </font>to the appropriate columns in the
        database. The set of value types of an <tt>DBView::update_iterator</tt>
        consists of a single type, <font size="2"
        face="Courier New">DataObj</font>. </td>
        <td valign="top">&nbsp; </td>
    </tr>
    <tr>
        <td valign="top"><tt>ParamObj</tt> </td>
        <td valign="top">The type of object that will be used to
        specify the postfix parameters to the <font size="2"
        face="Courier New">DBView</font>.</td>
        <td valign="top"><font size="2" face="Courier New">DefaultParamObj&lt;DataObj&gt;</font>&nbsp;
        </td>
    </tr>
</table>

<h3>Model of</h3>

<p><a
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
Iterator</a>. </p>

<h3>Type requirements</h3>

<p><font size="2" face="Courier New">DataObj </font>and <font
size="2" face="Courier New">ParamObj</font> must each fulfill the
following requirements:. </p>

<ul>
    <li>Be of a type that is not primitive or of type <font
        size="2" face="Courier New">string</font><font size="2">.</font></li>
    <li><font size="3">Have a publicly accessible copy
        constructor (the default is OK).</font></li>
    <li><font size="3">Have a publicly accessible assignment
        operator (the default is OK).</font></li>
</ul>

<h3>Public base classes</h3>

<p><font size="2" face="Courier New">DB_iterator&lt;DataObj,
ParamObj&gt;, iterator&lt;output_iterator_tag,
DataObj&gt;</font></p>

<h3>Members</h3>

<table border="2">
    <tr>
        <th>Member </th>
        <th>Where defined </th>
        <th>Description </th>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator()</tt> </td>
        <td valign="top"><tt>update_iterator</tt> </td>
        <td valign="top"><font size="3">Default constructor.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator(DBView&lt;DataObj,
        ParamObj&gt; &amp;view)</tt> </td>
        <td valign="top"><tt>update_iterator</tt> </td>
        <td valign="top"><font size="3">See below.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator(const DBView::update_iterator&amp;)</tt>
        </td>
        <td valign="top"><a
        href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
        Iterator</a> </td>
        <td valign="top">The copy constructor </td>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator&amp;
        operator=(const DBView update_iterator&amp;)</tt> </td>
        <td valign="top"><a
        href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
        Iterator</a> </td>
        <td valign="top">The assignment operator </td>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator&amp;
        operator*(), DBView::update_iterator&amp; operator=(const
        DataObj &amp;data)</tt></td>
        <td valign="top"><a
        href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
        Iterator</a> </td>
        <td valign="top">Proxy operators necessary to emulate <font
        size="2" face="Courier New">*it = data.</font> Return <font
        size="2" face="Courier New">*this</font><font size="3">.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator&amp;
        operator++()</tt> </td>
        <td valign="top"><a
        href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
        Iterator</a> </td>
        <td valign="top">Preincrement. Updates all <font size="2"
        face="Courier New">DataObj's </font>meeting the
        iterator's SQL query to the new value specified in the <font
        size="2" face="Courier New">DataObj </font><font size="3">to
        the </font><font size="2" face="Courier New">DBView. </font><font
        size="3">See Note </font><a href="#1"><font size="3">[1]</font></a><font
        size="3">.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>const DBView::update_iterator
        operator++(int)</tt> </td>
        <td valign="top"><a
        href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
        Iterator</a> </td>
        <td valign="top">Preincrement. Updates all <font size="2"
        face="Courier New">DataObj's </font>meeting the
        iterator's SQL query to the new value specified in the <font
        size="2" face="Courier New">DataObj </font><font size="3">to
        the </font><font size="2" face="Courier New">DBView.</font><font
        size="3"> See Note </font><a href="#1"><font size="3">[1]</font></a><font
        size="3">.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>void swap(DBView::update_iterator
        &amp;other)</tt></td>
        <td valign="top"><font size="2" face="Courier New">DBView::update_iterator</font>
        </td>
        <td valign="top">See below.</td>
    </tr> 

</table>

<h3>New members</h3>

<p>These members are not defined in the <a
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
Iterator</a> requirements or in <font size="2" face="Courier New">DB_iterator&lt;DataObj,
ParamObj&gt;</font>, but are specific to <tt>DBView::update_iterator</tt>.
</p>

<table border="2">
    <tr>
        <th>Function </th>
        <th>Description </th>
    </tr>
    <tr>
        <td valign="top"><tt>DBView::update_iterator(DBView&lt;DataObj,
        ParamObj&gt; &amp;view)</tt> </td>
        <td valign="top">Creates an <font size="2"
        face="Courier New">update_iterator</font> which refers to <font size="2"
        face="Courier New">view</font><font
        size="1" face="Courier New">.</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>void swap(DBView::update_iterator
        &amp;other)</tt></td>
        <td valign="top">Swap <font size="2" face="Courier New">*this</font>
        with <font size="2">other</font>.</td>
    </tr>
</table>

<h3>Notes</h3>

<p><a name="1"></a>[1] <font size="2" face="Courier New">operator++()</font>
is the operation that actually applies the update<font size="3">
to the database via the </font><font size="2" face="Courier New">DBView</font><font
size="3">. Each </font><font size="2" face="Courier New">DBView::update_iterator</font><font
size="1" face="Courier New"> </font><font size="3">internally
owns a </font><font size="2" face="Courier New">DBStmt</font><font
size="3"> object which is allocated and prepared when the
underlying ODBC statement handle is first needed and not before.
The handle is not opened until absolutely needed in order to make
copying and assigning these iterators an inexpensive operation.
The </font><font size="2" face="Courier New">DBStmt</font><font
size="3"> is executed once on each call to </font><font size="2"
face="Courier New">operator++()</font><font size="3">, whether
the prefix or postfix version.</font></p>

<h3>See also</h3>

<p><a href="db_iterator.htm"><font size="2" face="Courier New">DB_iterator</font></a>,
<a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
Iterator</a>, <a
href="http://www.sgi.com/tech/stl/InputIterator.html">Input
Iterator</a>.<br>
<br>
</p>


<hr>

<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>

<p>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -