• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/api_reference/C/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>DB-&gt;truncate()</title>
7    <link rel="stylesheet" href="apiReference.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
10    <link rel="up" href="db.html" title="Chapter��2.�� The DB Handle" />
11    <link rel="prev" href="dbsync.html" title="DB-&gt;sync()" />
12    <link rel="next" href="dbupgrade.html" title="DB-&gt;upgrade()" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">DB-&gt;truncate()</th>
19        </tr>
20        <tr>
21          <td width="20%" align="left"><a accesskey="p" href="dbsync.html">Prev</a>��</td>
22          <th width="60%" align="center">Chapter��2.��
23                The DB Handle
24        </th>
25          <td width="20%" align="right">��<a accesskey="n" href="dbupgrade.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="sect1" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title" style="clear: both"><a id="dbtruncate"></a>DB-&gt;truncate()</h2>
35          </div>
36        </div>
37      </div>
38      <pre class="programlisting">#include &lt;db.h&gt;
39
40int
41DB-&gt;truncate(DB *db,
42    DB_TXN *txnid, u_int32_t *countp, u_int32_t flags);  </pre>
43      <p>
44         The <code class="methodname">DB-&gt;truncate()</code> method empties the database, discarding all
45         records it contains.  The number of records discarded from the
46         database is returned in <span class="bold"><strong>countp</strong></span>.
47    </p>
48      <p>
49         When called on a database configured with secondary indices using the
50         <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a> 
51         method, the <code class="methodname">DB-&gt;truncate()</code> method truncates the primary database and
52         all secondary indices.  A count of the records discarded from the
53         primary database is returned.
54    </p>
55      <p>
56         It is an error to call the <code class="methodname">DB-&gt;truncate()</code> method on a database with
57         open cursors.
58    </p>
59      <p>
60         The <code class="methodname">DB-&gt;truncate()</code> <span>
61            <span>
62                  method returns a non-zero error value on failure and 0 on success.
63            </span>
64            
65        </span>
66    </p>
67      <div class="sect2" lang="en" xml:lang="en">
68        <div class="titlepage">
69          <div>
70            <div>
71              <h3 class="title"><a id="id1652212"></a>Parameters</h3>
72            </div>
73          </div>
74        </div>
75        <div class="sect3" lang="en" xml:lang="en">
76          <div class="titlepage">
77            <div>
78              <div>
79                <h4 class="title"><a id="id1652217"></a>countp</h4>
80              </div>
81            </div>
82          </div>
83          <p>
84                          The <span class="bold"><strong>countp</strong></span> parameter references
85                          memory into which  the number of records discarded from the database
86                          is copied.
87                     </p>
88        </div>
89        <div class="sect3" lang="en" xml:lang="en">
90          <div class="titlepage">
91            <div>
92              <div>
93                <h4 class="title"><a id="id1652330"></a>flags</h4>
94              </div>
95            </div>
96          </div>
97          <p>
98                          The <span class="bold"><strong>flags</strong></span> parameter is currently
99                          unused, and must be set to 0.
100                     </p>
101        </div>
102        <div class="sect3" lang="en" xml:lang="en">
103          <div class="titlepage">
104            <div>
105              <div>
106                <h4 class="title"><a id="id1652344"></a>txnid</h4>
107              </div>
108            </div>
109          </div>
110          <p>
111                          If the operation is part of an application-specified transaction, the
112                          <span class="bold"><strong>txnid</strong></span> parameter is a transaction
113                          handle returned from <a class="xref" href="txnbegin.html" title="DB_ENV-&gt;txn_begin()">DB_ENV-&gt;txn_begin()</a>; if the
114                          operation is part of a Berkeley DB Concurrent Data Store group, the
115                          <span class="bold"><strong>txnid</strong></span> parameter is a handle returned
116                          from <a class="xref" href="envcdsgroup_begin.html" title="DB_ENV-&gt;cdsgroup_begin()">DB_ENV-&gt;cdsgroup_begin()</a>;
117                          otherwise NULL. If no transaction handle is specified, but the
118                          operation occurs in a transactional database, the operation will be
119                          implicitly transaction protected.
120                     </p>
121        </div>
122      </div>
123      <div class="sect2" lang="en" xml:lang="en">
124        <div class="titlepage">
125          <div>
126            <div>
127              <h3 class="title"><a id="id1652232"></a>Errors</h3>
128            </div>
129          </div>
130        </div>
131        <p>
132                         The <code class="methodname">DB-&gt;truncate()</code> <span>
133            <span>
134                 method may fail and return one of the following non-zero errors:
135            </span>
136            
137        </span>
138                    </p>
139        <div class="sect3" lang="en" xml:lang="en">
140          <div class="titlepage">
141            <div>
142              <div>
143                <h4 class="title"><a id="id1652368"></a>DB_LOCK_DEADLOCK</h4>
144              </div>
145            </div>
146          </div>
147          <p>
148                A transactional database environment operation was selected to resolve
149                a deadlock.
150            </p>
151        </div>
152        <div class="sect3" lang="en" xml:lang="en">
153          <div class="titlepage">
154            <div>
155              <div>
156                <h4 class="title"><a id="id1652229"></a>DB_LOCK_NOTGRANTED</h4>
157              </div>
158            </div>
159          </div>
160          <p>
161                A Berkeley DB Concurrent Data Store database environment configured
162                for lock timeouts was unable to grant a lock in the allowed time.
163            </p>
164        </div>
165        <div class="sect3" lang="en" xml:lang="en">
166          <div class="titlepage">
167            <div>
168              <div>
169                <h4 class="title"><a id="id1652399"></a>EINVAL</h4>
170              </div>
171            </div>
172          </div>
173          <p>
174                If there are open cursors in the database; or if an invalid flag value or parameter was specified.
175            </p>
176        </div>
177      </div>
178      <div class="sect2" lang="en" xml:lang="en">
179        <div class="titlepage">
180          <div>
181            <div>
182              <h3 class="title"><a id="id1652315"></a>Class</h3>
183            </div>
184          </div>
185        </div>
186        <p>
187                <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a>  
188            </p>
189      </div>
190      <div class="sect2" lang="en" xml:lang="en">
191        <div class="titlepage">
192          <div>
193            <div>
194              <h3 class="title"><a id="id1652381"></a>See Also</h3>
195            </div>
196          </div>
197        </div>
198        <p>
199                     <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 
200                </p>
201      </div>
202    </div>
203    <div class="navfooter">
204      <hr />
205      <table width="100%" summary="Navigation footer">
206        <tr>
207          <td width="40%" align="left"><a accesskey="p" href="dbsync.html">Prev</a>��</td>
208          <td width="20%" align="center">
209            <a accesskey="u" href="db.html">Up</a>
210          </td>
211          <td width="40%" align="right">��<a accesskey="n" href="dbupgrade.html">Next</a></td>
212        </tr>
213        <tr>
214          <td width="40%" align="left" valign="top">DB-&gt;sync()��</td>
215          <td width="20%" align="center">
216            <a accesskey="h" href="index.html">Home</a>
217          </td>
218          <td width="40%" align="right" valign="top">��DB-&gt;upgrade()</td>
219        </tr>
220      </table>
221    </div>
222  </body>
223</html>
224