Debian Codegraph @

docs/api_reference/CXX/dbtruncate.html

raw symbols SCIP
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::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::sync()" />
12 <link rel="next" href="dbupgrade.html" title="Db::upgrade()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">Db::truncate()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbsync.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 2. 
26 The Db Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="dbupgrade.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="dbtruncate"></a>Db::truncate()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 Db::truncate(DbTxn *txnid, u_int32_t *countp, u_int32_t flags);</pre>
45 <p>
46 The <code class="methodname">Db::truncate()</code> method empties the database, discarding all
47 records it contains. The number of records discarded from the
48 database is returned in <span class="bold"><strong>countp</strong></span>.
49 </p>
50 <p>
51 When called on a database configured with secondary indices using the
52 <a class="xref" href="dbassociate.html" title="Db::associate()">Db::associate()</a>
53 method, the <code class="methodname">Db::truncate()</code> method truncates the primary database and
54 all secondary indices. A count of the records discarded from the
55 primary database is returned.
56 </p>
57 <p>
58 It is an error to call the <code class="methodname">Db::truncate()</code> method on a database with
59 open cursors.
60 </p>
61 <p>
62 The <code class="methodname">Db::truncate()</code> <span>
63
64 <span>
65 method either returns a non-zero error value or throws an
66 exception that encapsulates a non-zero error value on
67 failure, and returns 0 on success.
68 </span>
69 </span>
70 </p>
71 <div class="sect2" lang="en" xml:lang="en">
72 <div class="titlepage">
73 <div>
74 <div>
75 <h3 class="title"><a id="idp5975160"></a>Parameters</h3>
76 </div>
77 </div>
78 </div>
79 <div class="sect3" lang="en" xml:lang="en">
80 <div class="titlepage">
81 <div>
82 <div>
83 <h4 class="title"><a id="idp5951776"></a>txnid</h4>
84 </div>
85 </div>
86 </div>
87 <p>
88 If the operation is part of an application-specified transaction, the
89 <span class="bold"><strong>txnid</strong></span> parameter is a transaction
90 handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>; if the
91 operation is part of a Berkeley DB Concurrent Data Store group, the
92 <span class="bold"><strong>txnid</strong></span> parameter is a handle returned
93 from <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a>;
94 otherwise NULL. If no transaction handle is specified, but the
95 operation occurs in a transactional database, the operation will be
96 implicitly transaction protected.
97 </p>
98 </div>
99 <div class="sect3" lang="en" xml:lang="en">
100 <div class="titlepage">
101 <div>
102 <div>
103 <h4 class="title"><a id="idp5990384"></a>countp</h4>
104 </div>
105 </div>
106 </div>
107 <p>
108 The <span class="bold"><strong>countp</strong></span> parameter references
109 memory into which the number of records discarded from the database
110 is copied.
111 </p>
112 </div>
113 <div class="sect3" lang="en" xml:lang="en">
114 <div class="titlepage">
115 <div>
116 <div>
117 <h4 class="title"><a id="idp5995384"></a>flags</h4>
118 </div>
119 </div>
120 </div>
121 <p>
122 The <span class="bold"><strong>flags</strong></span> parameter is currently
123 unused, and must be set to 0.
124 </p>
125 </div>
126 </div>
127 <div class="sect2" lang="en" xml:lang="en">
128 <div class="titlepage">
129 <div>
130 <div>
131 <h3 class="title"><a id="idp5982536"></a>Errors</h3>
132 </div>
133 </div>
134 </div>
135 <p>
136 The <code class="methodname">Db::truncate()</code> <span>
137
138 <span>
139 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a>
140 exception, encapsulating one of the following non-zero errors, or return one
141 of the following non-zero errors:
142 </span>
143 </span>
144 </p>
145 <div class="sect3" lang="en" xml:lang="en">
146 <div class="titlepage">
147 <div>
148 <div>
149 <h4 class="title"><a id="idp5979640"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
150 </div>
151 </div>
152 </div>
153 <p>
154 A transactional database environment operation was selected to resolve
155 a deadlock.
156 </p>
157 <p>
158 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
159 your Berkeley DB API is configured to throw exceptions.
160 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
161 </p>
162 </div>
163 <div class="sect3" lang="en" xml:lang="en">
164 <div class="titlepage">
165 <div>
166 <div>
167 <h4 class="title"><a id="idp5992408"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
168 </div>
169 </div>
170 </div>
171 <p>
172 A Berkeley DB Concurrent Data Store database environment configured
173 for lock timeouts was unable to grant a lock in the allowed time.
174 </p>
175 <p>
176 You attempted to open a database handle that is configured
177 for no waiting exclusive locking, but the exclusive lock could not be
178 immediately obtained. See
179 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
180 for more information.
181 </p>
182 <p>
183 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
184 your Berkeley DB API is configured to throw exceptions.
185 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
186 </p>
187 </div>
188 <div class="sect3" lang="en" xml:lang="en">
189 <div class="titlepage">
190 <div>
191 <div>
192 <h4 class="title"><a id="idp5901200"></a>EINVAL</h4>
193 </div>
194 </div>
195 </div>
196 <p>
197 If there are open cursors in the database; or if an invalid flag value or parameter was specified.
198 </p>
199 </div>
200 </div>
201 <div class="sect2" lang="en" xml:lang="en">
202 <div class="titlepage">
203 <div>
204 <div>
205 <h3 class="title"><a id="idp5998016"></a>Class</h3>
206 </div>
207 </div>
208 </div>
209 <p>
210 <a class="link" href="db.html" title="Chapter 2.  The Db Handle">Db</a>
211 </p>
212 </div>
213 <div class="sect2" lang="en" xml:lang="en">
214 <div class="titlepage">
215 <div>
216 <div>
217 <h3 class="title"><a id="idp5970480"></a>See Also</h3>
218 </div>
219 </div>
220 </div>
221 <p>
222 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a>
223 </p>
224 </div>
225 </div>
226 <div class="navfooter">
227 <hr />
228 <table width="100%" summary="Navigation footer">
229 <tr>
230 <td width="40%" align="left"><a accesskey="p" href="dbsync.html">Prev</a> </td>
231 <td width="20%" align="center">
232 <a accesskey="u" href="db.html">Up</a>
233 </td>
234 <td width="40%" align="right"> <a accesskey="n" href="dbupgrade.html">Next</a></td>
235 </tr>
236 <tr>
237 <td width="40%" align="left" valign="top">Db::sync() </td>
238 <td width="20%" align="center">
239 <a accesskey="h" href="index.html">Home</a>
240 </td>
241 <td width="40%" align="right" valign="top"> Db::upgrade()</td>
242 </tr>
243 </table>
244 </div>
245 </body>
246 </html>