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

📄 delete_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 页
字号:
<html>


<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
  -- Copyright 2000
  -- Michael Gradman & Corwin Joy
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Corwin Joy & Michael Gradman make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  --
  -- Copyright (c) 1996-1999
  -- Silicon Graphics Computer Systems, Inc.
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Silicon Graphics makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -- Copyright (c) 1994
  -- Hewlett-Packard Company
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Hewlett-Packard Company makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -->
<!-- Generated by htmldoc -->
<title>DBView&lt;DataObj,ParamObj&gt;::delete_iterator</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">

<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>

<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p> 

<h1>DBView&lt;DataObj, ParamObj&gt;::delete_iterator</h1>

 


















<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td><img src="iterator.gif" width="194" height="38"></td>
        <td align="right"><img src="type.gif" width="194"
        height="39"></td>
    </tr>
    <tr>
        <td valign="top"><b>Category</b>: iterators</td>
        <td align="right" valign="top"><b>Component type</b>:
        type</td>
    </tr>
</table>
<h3>Description</h3>

<p><tt>DBView&lt;DataObj, ParamObj&gt;::delete_iterator</tt> is
an <a href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
Iterator</a> that performs the deletion of objects of type <font
size="2" face="Courier New">DataObj</font> from a particular <font
size="2" face="Courier New">DBView</font><font size="2"> </font>(and
thus the database). The actual <font size="2" face="Courier New">DataObj
</font><font size="3">that the</font><font size="4"> </font><font
size="2" face="Courier New">delete_iterator</font><font size="2">
</font>references specifies the parameters of what <font size="2"
face="Courier New">DataObj's </font>to delete from the database.
To specify more parameters to refine the delete, define a <tt>ParamObj
</tt><font size="4" face="Times New Roman"><tt>and</tt></font><tt>
</tt><a href="BPA.htm"><tt>BPA</tt></a><tt> </tt>in the
underlying <tt>DBView</tt>. The <font size="2" face="Courier New">delete_iterator
</font>generates the following SQL statement to delete records
from the database: <font size="2" face="Courier New">&quot;DELETE
FROM &quot; + tablename_from_view + &quot; WHERE &quot; + &quot;&lt;field1_from_BCA&gt;=(?)
AND &lt;field2_from_BCA&gt;=(?) AND ... &quot; +
posfix_clause_from_view. </font><font size="3">The first set of
parameters in the </font><font size="2" face="Courier New">WHERE </font><font
size="3">clause from the</font><font size="2" face="Courier New">
</font><a href="BCA.htm"><tt>BCA</tt></a><font size="2"
face="Courier New"> </font><font size="3">will be automatically
bound to fields in the</font><font size="2" face="Courier New">
DataObj. </font><font size="3">These parameters are set
automatically upon assignment to the </font><font size="2"
face="Courier New">delete_iterator.</font><font size="3">&nbsp;
Any additional parameters in the postfix clause will be bound to
the</font><font size="2" face="Courier New"> ParamObj. </font>Note
that all of the restrictions of an <a
href="http://www.sgi.com/tech/stl/OutputIterator.html">Output
Iterator</a> must be obeyed, including the restrictions on the
ordering of <tt>operator*</tt> and <tt>operator++</tt> operations.
</p>

<h3>Definition</h3>

<p>Defined in the <font size="2" face="Courier New">delete_iterator.h</font>
header file. </p>

<h3>Example:</h3>

<p><pre><code><span class="codeComment">// Delete objects from the database via a delete_iterator</span>

class Example
{
  public:                                <span class="codeComment">// tablename.columnname:</span>
	int exampleInt;                 <span class="codeComment">// DB_EXAMPLE.INT_VALUE</span>
	string exampleStr;              <span class="codeComment">// DB_EXAMPLE.STRING_VALUE</span>
	double exampleDouble;           <span class="codeComment">// DB_EXAMPLE.DOUBLE_VALUE</span>
	long exampleLong;               <span class="codeComment">// DB_EXAMPLE.EXAMPLE_LONG</span>
	TIMESTAMP_STRUCT exampleDate;   <span class="codeComment">// DB_EXAMPLE.EXAMPLE_DATE</span>

	Example(int exInt, const string &amp;exStr, double exDouble, long exLong,
		const TIMESTAMP_STRUCT &amp;exDate) :
	   exampleInt(exInt), exampleStr(exStr), exampleDouble(exDouble), exampleLong(exLong),
	   exampleDate(exDate)
	{ }

};

class BCAExampleObj
{
public:
	void operator()(BoundIOs &amp;boundIOs, Example &amp;rowbuf)
	{
		boundIOs[&quot;INT_VALUE&quot;] == rowbuf.exampleInt;
		boundIOs[&quot;STRING_VALUE&quot;] == rowbuf.exampleStr;
		boundIOs[&quot;DOUBLE_VALUE&quot;] == rowbuf.exampleDouble;
		boundIOs[&quot;EXAMPLE_LONG&quot;] == rowbuf.exampleLong;
		boundIOs[&quot;EXAMPLE_DATE&quot;] == rowbuf.exampleDate;
	}
};

class ExampleParamObj
{
    public:
       	int lowIntValue;
	string strValue;
};

class BPAParamObj
{
public:
	void operator()(BoundIOs &amp;boundIOs, ExampleParamObj &amp;paramObj)
	{
		boundIOs[0] == paramObj.strValue;
		boundIOs[1] == paramObj.lowIntValue;
	}

};


<span class="codeComment">// Delete rows matching the specified Example objects from the database</span>
void DeleteData()
{
	<span class="codeComment">// construct view</span>
	DBView&lt;Example, ExampleParamObj&gt;
	view(&quot;DB_EXAMPLE&quot;, BCAExampleObj(), &quot;OR STRING_VALUE = (?) OR INT_VALUE = (?)&quot;, BPAParamObj());

	<span class="codeComment">// build a deleter for the view

	// *** SQL Query Generated for this delete_iterator:&quot; ***
	// *** (Note: All column and field names that were generated by the BCA are alphabetized due to our implementation) ***
 	// &quot;DELETE FROM DB_EXAMPLE WHERE EXAMPLE_DATE = (?) AND STRING_VALUE = (?) &quot;
	// &quot;OR STRING_VALUE = (?) OR INT_VALUE = (?)&quot;</span>

	DBView&lt;Example, ExampleParamObj, BCAExampleObj, BPAParamObj&gt;::delete_iterator
	exampleDeleter = view;

	<span class="codeComment">// now set the parameters indicating which rows we want to delete</span>
	exampleDeleter-&gt;exampleStr = &quot;Example&quot;;

	TIMESTAMP_STRUCT y2k = {2000, 1, 1, 0, 0, 0, 0};
	exampleDeleter-&gt;exampleDate = y2k;

	exampleDeleter.Params().strValue = &quot;Find Me&quot;;
	exampleDeleter.Params().lowIntValue = 18;

	<span class="codeComment">// execute the delete</span>
	exampleDeleter++;

	cout &lt;&lt; exampleDeleter.GetLastCount()

⌨️ 快捷键说明

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