Debian Codegraph @

docs/api_reference/C/dbcget.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>DBcursor-&gt;get()</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="dbc.html" title="Chapter 3.  The DBcursor Handle" />
11 <link rel="prev" href="dbcdup.html" title="DBcursor-&gt;dup()" />
12 <link rel="next" href="dbcget_priority.html" title="DBcursor-&gt;get_priority()" />
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">DBcursor-&gt;get()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="dbcdup.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 3. 
26 The DBcursor Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="dbcget_priority.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="dbcget"></a>DBcursor-&gt;get()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DBcursor-&gt;get(DBC *DBcursor,
45 DBT *key, DBT *data, u_int32_t flags);
46
47 int
48 DBcursor-&gt;pget(DBC *DBcursor,
49 DBT *key, DBT *pkey, DBT *data, u_int32_t flags); </pre>
50 <p>
51 The <code class="methodname">DBcursor-&gt;get()</code> method retrieves key/data pairs from the
52 database. The address and length of the key are returned in the
53 object to which <span class="bold"><strong>key</strong></span> refers (except
54 for the case of the DB_SET flag, in which the <span class="bold"><strong>key</strong></span> object is unchanged), and the address and
55 length of the data are returned in the object to which <span class="bold"><strong>data</strong></span> refers.
56 </p>
57 <p>
58 When called on a cursor opened on a database that has been made into a
59 secondary index using the
60 <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a> method, the
61 <code class="methodname">DBcursor-&gt;get()</code> and <code class="methodname">DBcursor-&gt;pget()</code>
62 methods return the key from the
63 secondary index and the data item from the primary database. In
64 addition, the <code class="methodname">DBcursor-&gt;pget()</code> method returns the key from the
65 primary database. In databases that are not secondary indices, the
66 <code class="methodname">DBcursor-&gt;pget()</code> method will always fail.
67 </p>
68 <p>
69 Modifications to the database during a sequential scan will be
70 reflected in the scan; that is, records inserted behind a cursor will
71 not be returned while records inserted in front of a cursor will be
72 returned.
73 </p>
74 <p>
75 In Queue and Recno databases, missing entries (that is, entries that
76 were never explicitly created or that were created and then deleted)
77 will be skipped during a sequential scan.
78 </p>
79 <p>
80 Unless otherwise specified, the <code class="methodname">DBcursor-&gt;get()</code> <span>
81 <span>
82 method returns a non-zero error value on failure and 0 on success.
83 </span>
84
85 </span>
86 </p>
87 <p>
88 If <code class="methodname">DBcursor-&gt;get()</code> fails for any reason, the state of the cursor will
89 be unchanged.
90 </p>
91 <div class="sect2" lang="en" xml:lang="en">
92 <div class="titlepage">
93 <div>
94 <div>
95 <h3 class="title"><a id="idp50860968"></a>Parameters</h3>
96 </div>
97 </div>
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="idp50895144"></a>key</h4>
104 </div>
105 </div>
106 </div>
107 <p>
108 The key <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> operated on.
109 </p>
110 <p>
111 If <a class="link" href="dbt.html#dbt_DB_DBT_PARTIAL">DB_DBT_PARTIAL</a>
112 is set for the DBT used for this parameter,
113 and if the <span class="bold"><strong>flags</strong></span> parameter
114 is set to
115 <a class="link" href="dbcget.html#dbcget_DB_GET_BOTH">DB_GET_BOTH</a>,
116 <a class="link" href="dbcget.html#dbcget_DB_GET_BOTH_RANGE">DB_GET_BOTH_RANGE</a>,
117 <a class="link" href="dbcget.html#dbcget_DB_SET">DB_SET</a>, or
118 <a class="link" href="dbcget.html#dbcget_DB_SET_RECNO">DB_SET_RECNO</a>,
119 then this method will fail and return <code class="literal">EINVAL</code>.
120 </p>
121 </div>
122 <div class="sect3" lang="en" xml:lang="en">
123 <div class="titlepage">
124 <div>
125 <div>
126 <h4 class="title"><a id="idp50899600"></a>pkey</h4>
127 </div>
128 </div>
129 </div>
130 <p>
131 The return key from the primary database.
132 If
133 <a class="link" href="dbt.html#dbt_DB_DBT_PARTIAL">DB_DBT_PARTIAL</a>
134 is set for the DBT used for this parameter,
135 then this method will fail and return <code class="literal">EINVAL</code>.
136 </p>
137 </div>
138 <div class="sect3" lang="en" xml:lang="en">
139 <div class="titlepage">
140 <div>
141 <div>
142 <h4 class="title"><a id="idp50890360"></a>data</h4>
143 </div>
144 </div>
145 </div>
146 <p>
147 The data <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a> operated on.
148 </p>
149 </div>
150 <div class="sect3" lang="en" xml:lang="en">
151 <div class="titlepage">
152 <div>
153 <div>
154 <h4 class="title"><a id="idp50875128"></a>flags</h4>
155 </div>
156 </div>
157 </div>
158 <p>
159 The <span class="bold"><strong>flags</strong></span> parameter must be set to
160 one of the following values:
161 </p>
162 <div class="itemizedlist">
163 <ul type="disc">
164 <li>
165 <p><a id="dbcget_DB_CURRENT"></a>
166 <code class="literal">DB_CURRENT</code>
167 </p>
168 <p>
169 Return the key/data pair to which the cursor refers.
170 </p>
171 <p>
172 The <code class="methodname">DBcursor-&gt;get()</code> method
173 will return
174 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_KEYEMPTY" class="olink">DB_KEYEMPTY</a>
175 if DB_CURRENT is set and the cursor key/data pair
176 was deleted.
177 </p>
178 </li>
179 <li>
180 <p><a id="dbcget_DB_FIRST"></a>
181 <code class="literal">DB_FIRST</code>
182 </p>
183 <p>
184 The cursor is set to refer to the first key/data
185 pair of the database, and that pair is returned.
186 If the first key has duplicate values, the first
187 data item in the set of duplicates is returned.
188 </p>
189 <p>
190 If the database is a Queue or Recno database,
191 <code class="methodname">DBcursor-&gt;get()</code> using the
192 DB_FIRST flag will ignore any keys that exist but
193 were never explicitly created by the application,
194 or were created and later deleted.
195 </p>
196 <p>
197 The <code class="methodname">DBcursor-&gt;get()</code> method
198 will return
199 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
200 if DB_FIRST is set and the database is empty.
201 </p>
202 </li>
203 <li>
204 <p><a id="dbcget_DB_GET_BOTH"></a>
205 <code class="literal">DB_GET_BOTH</code>
206 </p>
207 <p>
208 Move the cursor to the specified key/data pair of
209 the database. The cursor is positioned to a
210 key/data pair if both the key and data match the
211 values provided on the key and data parameters.
212 </p>
213 <p>
214 In all other ways, this flag is identical to the
215 <a class="link" href="dbcget.html#dbcget_DB_SET">DB_SET</a>
216 flag.
217 </p>
218 <p>
219 When used with
220 <code class="methodname">DBcursor-&gt;pget()</code> on a
221 secondary index handle, both the secondary and
222 primary keys must be matched by the secondary and
223 primary key item in the database. It is an error
224 to use the DB_GET_BOTH flag with the
225 <code class="methodname">DBcursor-&gt;get()</code> version
226 of this method and a cursor that has been opened on a secondary index
227 handle.
228 </p>
229 </li>
230 <li>
231 <p><a id="dbcget_DB_GET_BOTH_RANGE"></a>
232 <code class="literal">DB_GET_BOTH_RANGE</code>
233 </p>
234 <p>
235 Move the cursor to the specified key/data pair of the
236 database. The key parameter must be an exact match with a
237 key in the database. The data item retrieved is the item in
238 a duplicate set that is the smallest value which is greater than or equal
239 to the value provided by the data parameter (as determined by the comparison
240 function). If this flag is specified on a database
241 configured without sorted duplicate support, the behavior
242 is identical to the <code class="literal">DB_GET_BOTH</code> flag. Returns the datum
243 associated with the given key/data pair.
244 </p>
245 <p>
246 In all other ways, this flag is identical to the
247 <a class="link" href="dbcget.html#dbcget_DB_GET_BOTH">DB_GET_BOTH</a>
248 flag.
249 </p>
250 </li>
251 <li>
252 <p><a id="dbcget_DB_GET_RECNO"></a>
253 <code class="literal">DB_GET_RECNO</code>
254 </p>
255 <p>
256 Return the record number associated with the cursor. The record
257 number will be returned in <span class="bold"><strong>data</strong></span>, as
258 described in <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a>. The
259 <span class="bold"><strong>key</strong></span> parameter is ignored.
260 </p>
261 <p>
262 For DB_GET_RECNO to be specified, the underlying database must be of
263 type Btree, and it must have been created with the
264 <a class="link" href="dbset_flags.html#dbset_flags_DB_RECNUM">DB_RECNUM</a>
265 flag.
266 </p>
267 <p>
268 When called on a cursor opened on a database that has been made into a
269 secondary index, the <code class="methodname">DBcursor-&gt;get()</code> and
270 <code class="methodname">DBcursor-&gt;pget()</code> methods return the record
271 number of the primary database in <span class="bold"><strong>data</strong></span>.
272 In addition, the <code class="methodname">DBcursor-&gt;pget()</code>
273 method returns the record number of the secondary index in <span class="bold"><strong>pkey</strong></span>. If either underlying database is not of
274 type Btree or is not created with the
275 <a class="link" href="dbset_flags.html#dbset_flags_DB_RECNUM">DB_RECNUM</a>
276 flag, the out-of-band record number of 0 is returned.
277 </p>
278 </li>
279 <li>
280 <p><a id="dbcget_DB_JOIN_ITEM"></a>
281 <code class="literal">DB_JOIN_ITEM</code>
282 </p>
283 <p>
284 Do not use the data value found in all of the cursors as a lookup key
285 for the primary database, but simply return it in the key parameter
286 instead. The data parameter is left unchanged.
287 </p>
288 <p>
289 For DB_JOIN_ITEM to be specified, the underlying cursor must have been
290 returned from the <a class="xref" href="dbjoin.html" title="DB-&gt;join()">DB-&gt;join()</a> method.
291 </p>
292 <p>
293 This flag is not supported for Heap databases.
294 </p>
295 </li>
296 <li>
297 <p><a id="dbcget_DB_LAST"></a>
298 <code class="literal">DB_LAST</code>
299 </p>
300 <p>
301 The cursor is set to refer to the last key/data pair of the database,
302 and that pair is returned. If the last key has duplicate values, the
303 last data item in the set of duplicates is returned.
304 </p>
305 <p>
306 If the database is a Queue or Recno database,
307 <code class="methodname">DBcursor-&gt;get()</code> using the
308 DB_LAST flag will ignore any keys that exist but
309 were never explicitly created by the application,
310 or were created and later deleted.
311 </p>
312 <p>
313 The <code class="methodname">DBcursor-&gt;get()</code> method
314 will return
315 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
316 if DB_LAST is set and the database is empty.
317 </p>
318 </li>
319 <li>
320 <p><a id="dbcget_DB_NEXT"></a>
321 <code class="literal">DB_NEXT</code>
322 </p>
323 <p>
324 If the cursor is not yet initialized, DB_NEXT is identical to
325 DB_FIRST. Otherwise, the cursor is moved to the next key/data pair of
326 the database, and that pair is returned. In the presence of duplicate
327 key values, the value of the key may not change.
328 </p>
329 <p>
330 If the database is a Queue or Recno database,
331 <code class="methodname">DBcursor-&gt;get()</code> using the
332 DB_NEXT flag will skip any keys that exist but
333 were never explicitly created by the application,
334 or those that were created and later deleted.
335 </p>
336 <p>
337 The <code class="methodname">DBcursor-&gt;get()</code> method
338 will return
339 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
340 if DB_NEXT is set and the cursor is already on the
341 last record in the database.
342 </p>
343 </li>
344 <li>
345 <p><a id="dbcget_DB_NEXT_DUP"></a>
346 <code class="literal">DB_NEXT_DUP</code>
347 </p>
348 <p>
349 If the next key/data pair of the database is a duplicate data record
350 for the current key/data pair, the cursor is moved to the next
351 key/data pair of the database, and that pair is returned.
352 </p>
353 <p>
354 The <code class="methodname">DBcursor-&gt;get()</code> method
355 will return
356 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
357 if DB_NEXT_DUP is set and the next key/data pair
358 of the database is not a duplicate data record for
359 the current key/data pair.
360 </p>
361 <p>
362 If using a Heap database, this flag results in this
363 method returning
364 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>.
365 </p>
366 </li>
367 <li>
368 <p><a id="dbcget_DB_NEXT_NODUP"></a>
369 <code class="literal">DB_NEXT_NODUP</code>
370 </p>
371 <p>
372 If the cursor is not yet initialized, DB_NEXT_NODUP is identical to
373 DB_FIRST. Otherwise, the cursor is moved to the next non-duplicate
374 key of the database, and that key/data pair is returned.
375 </p>
376 <p>
377 If the database is a Queue or Recno database,
378 <code class="methodname">DBcursor-&gt;get()</code> using the
379 DB_NEXT_NODUP flag will ignore any keys that exist
380 but were never explicitly created by the
381 application, or those that were created and later
382 deleted.
383 </p>
384 <p>
385 The <code class="methodname">DBcursor-&gt;get()</code> method
386 will return
387 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
388 if DB_NEXT_NODUP is set and no non-duplicate
389 key/data pairs exist after the cursor position in
390 the database.
391 </p>
392 <p>
393 If using a Heap database, this flag is identical to
394 the <code class="literal">DB_NEXT</code> flag.
395 </p>
396 </li>
397 <li>
398 <p><a id="dbcget_DB_PREV"></a>
399 <code class="literal">DB_PREV</code>
400 </p>
401 <p>
402 If the cursor is not yet initialized, DB_PREV is identical to DB_LAST.
403 Otherwise, the cursor is moved to the previous key/data pair of the
404 database, and that pair is returned. In the presence of duplicate key
405 values, the value of the key may not change.
406 </p>
407 <p>
408 If the database is a Queue or Recno database,
409 <code class="methodname">DBcursor-&gt;get()</code> using the
410 DB_PREV flag will skip any keys that exist but
411 were never explicitly created by the application,
412 or those that were created and later deleted.
413 </p>
414 <p>
415 The <code class="methodname">DBcursor-&gt;get()</code> method
416 will return
417 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
418 if DB_PREV is set and the cursor is already on the
419 first record in the database.
420 </p>
421 </li>
422 <li>
423 <p><a id="dbcget_DB_PREV_DUP"></a>
424 <code class="literal">DB_PREV_DUP</code>
425 </p>
426 <p>
427 If the previous key/data pair of the database is a duplicate data
428 record for the current key/data pair, the cursor is moved to the
429 previous key/data pair of the database, and that pair is returned.
430 </p>
431 <p>
432 The <code class="methodname">DBcursor-&gt;get()</code> method
433 will return
434 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
435 if DB_PREV_DUP is set and the previous key/data
436 pair of the database is not a duplicate data
437 record for the current key/data pair.
438 </p>
439 <p>
440 If using a Heap database, this flag results in this
441 method returning
442 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>.
443 </p>
444 </li>
445 <li>
446 <p><a id="dbcget_DB_PREV_NODUP"></a>
447 <code class="literal">DB_PREV_NODUP</code>
448 </p>
449 <p>
450 If the cursor is not yet initialized,
451 DB_PREV_NODUP is identical to DB_LAST. Otherwise,
452 the cursor is moved to the previous non-duplicate
453 key of the database, and that key/data pair is
454 returned.
455 </p>
456 <p>
457 If the database is a Queue or Recno database,
458 <code class="methodname">DBcursor-&gt;get()</code> using the
459 DB_PREV_NODUP flag will ignore any keys that exist
460 but were never explicitly created by the
461 application, or those that were created and later
462 deleted.
463 </p>
464 <p>
465 The <code class="methodname">DBcursor-&gt;get()</code> method
466 will return
467 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
468 if DB_PREV_NODUP is set and no non-duplicate
469 key/data pairs exist before the cursor position in
470 the database.
471 </p>
472 <p>
473 If using a Heap database, this flag is identical to
474 the <code class="literal">DB_PREV</code> flag.
475 </p>
476 </li>
477 <li>
478 <p><a id="dbcget_DB_SET"></a>
479 <code class="literal">DB_SET</code>
480 </p>
481 <p>
482 Move the cursor to the specified key/data pair of the database, and
483 return the datum associated with the given key.
484 </p>
485 <p>
486 The <code class="methodname">DBcursor-&gt;get()</code> method will return
487 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
488 if DB_SET is set and no matching keys are found.
489 The <code class="methodname">DBcursor-&gt;get()</code> method
490 will return
491 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_KEYEMPTY" class="olink">DB_KEYEMPTY</a>
492 if DB_SET is set and the database is a Queue or
493 Recno database, and the specified key exists, but
494 was never explicitly created by the application or
495 was later deleted. In the presence of duplicate key
496 values, <code class="methodname">DBcursor-&gt;get()</code> will
497 return the first data item for the given key.
498 </p>
499 </li>
500 <li>
501 <p><a id="dbcget_DB_SET_RANGE"></a>
502 <code class="literal">DB_SET_RANGE</code>
503 </p>
504 <p>
505 Move the cursor to the specified key/data pair of the
506 database. In the case of the Btree access method, the key
507 is returned as well as the data item and the returned
508 key/data pair is the smallest key greater than or equal to
509 the specified key (as determined by the Btree comparison
510 function), permitting partial key matches and range
511 searches.
512 </p>
513 <p>
514 In all other ways the behavior of this flag is the same
515 as the
516 <a class="link" href="dbcget.html#dbcget_DB_SET">DB_SET</a> flag.
517 </p>
518 </li>
519 <li>
520 <p><a id="dbcget_DB_SET_RECNO"></a>
521 <code class="literal">DB_SET_RECNO</code>
522 </p>
523 <p>
524 Move the cursor to the specific numbered record of
525 the database, and return the associated key/data
526 pair. The <span class="bold"><strong>data</strong></span>
527 field of the specified
528 <span class="bold"><strong>key</strong></span> must be a pointer
529 to a memory location from which a
530 <code class="literal">db_recno_t</code> may be read, as
531 described in
532 <a class="link" href="dbt.html" title="Chapter 4.  The DBT Handle">DBT</a>. This memory
533 location will be read to determine the record to
534 be retrieved.
535 </p>
536 <p>
537 For DB_SET_RECNO to be specified, the underlying database must be of
538 type Btree, and it must have been created with the
539 <a class="link" href="dbset_flags.html#dbset_flags_DB_RECNUM">DB_RECNUM</a>
540 flag.
541 </p>
542 </li>
543 </ul>
544 </div>
545 <p>
546 In addition, the following flags may be set by bitwise inclusively
547 <span class="bold"><strong>OR</strong></span>'ing them into the <span class="bold"><strong>flags</strong></span> parameter:
548 </p>
549 <div class="itemizedlist">
550 <ul type="disc">
551 <li>
552 <p>
553 <code class="literal">DB_IGNORE_LEASE</code>
554 </p>
555 <p>
556 This flag is relevant only when using a replicated
557 environment.
558 </p>
559 <p>
560 Return the data item irrespective of the state of
561 master leases. The item will be returned under
562 all conditions: if master leases are not
563 configured, if the request is made to a client, if
564 the request is made to a master with a valid
565 lease, or if the request is made to a master
566 without a valid lease.
567 </p>
568 </li>
569 <li>
570 <p><a id="dbcget_DB_READ_COMMITTED"></a>
571 <code class="literal">DB_READ_COMMITTED</code>
572 </p>
573 <p>
574 Configure a transactional get operation to have degree 2 isolation
575 (the read is not repeatable).
576 </p>
577 </li>
578 <li>
579 <p>
580 <code class="literal">DB_READ_UNCOMMITTED</code>
581 </p>
582 <p>
583 Database items read during a transactional call will have degree 1
584 isolation, including modified but not yet committed data. Silently
585 ignored if the
586 <a class="link" href="dbopen.html#dbopen_DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a>
587 flag was not specified when the underlying database was opened.
588 </p>
589 </li>
590 <li>
591 <p><a id="dbcget_DB_MULTIPLE"></a>
592 <code class="literal">DB_MULTIPLE</code>
593 </p>
594 <p>
595 Return multiple data items in the <span class="bold"><strong>data</strong></span> parameter.
596 </p>
597 <p>
598 In the case of Btree or Hash databases, duplicate data items for the
599 current key, starting at the current cursor position, are entered into
600 the buffer. Subsequent calls with both the DB_NEXT_DUP and
601 DB_MULTIPLE flags specified will return additional duplicate data
602 items associated with the current key or
603 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
604 if there are no additional duplicate data items to
605 return. Subsequent calls with both the DB_NEXT
606 and DB_MULTIPLE flags specified will return
607 additional duplicate data items associated with
608 the current key or if there are no additional
609 duplicate data items will return the next key and
610 its data items or
611 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
612 if there are no additional keys in the database.
613 </p>
614 <p>
615 In the case of Queue, Recno, or Heap databases,
616 data items starting at the current cursor position
617 are entered into the buffer. The record number
618 (or the RID, in the case of Heap) of
619 the first record will be returned in the
620 <span class="bold"><strong>key</strong></span> parameter.
621 For Queue and Recno, the record number of each
622 subsequent returned record must be calculated from
623 this value. For Heap databases, the RID of
624 subsequent returned records cannot be known. Subsequent
625 calls with the DB_MULTIPLE flag specified will
626 return additional data items or
627 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
628 if there are no additional data items to return.
629 </p>
630 <p>
631 The buffer to which the <span class="bold"><strong>data</strong></span>
632 parameter refers must be provided from user memory (see
633 <a class="link" href="dbt.html#dbt_DB_DBT_USERMEM">DB_DBT_USERMEM</a> ).
634 The buffer must be at least as large as the page size of the
635 underlying database, aligned for unsigned integer access, and be a
636 multiple of 1024 bytes in size. If the buffer size is insufficient,
637 then upon return from the call the size field of the <span class="bold"><strong>data</strong></span> parameter will have been set to an
638 estimated buffer size, and the error DB_BUFFER_SMALL is returned.
639 (The size is an estimate as the exact size needed may not be known
640 until all entries are read. It is best to initially provide a
641 relatively large buffer, but applications should be prepared to resize
642 the buffer as necessary and repeatedly call the method.)
643 </p>
644 <p>
645 The multiple data items can be iterated over using the
646 <span>
647 <a class="xref" href="DB_MULTIPLE_NEXT.html" title="DB_MULTIPLE_NEXT">DB_MULTIPLE_NEXT</a> macro.
648 </span>
649
650 </p>
651 <p>
652 The DB_MULTIPLE flag may only be used with the DB_CURRENT, DB_FIRST,
653 DB_GET_BOTH, DB_GET_BOTH_RANGE, DB_NEXT, DB_NEXT_DUP, DB_NEXT_NODUP,
654 DB_SET, DB_SET_RANGE, and DB_SET_RECNO options. The DB_MULTIPLE flag
655 may not be used when accessing databases made into secondary indices
656 using the <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a> method.
657 </p>
658 </li>
659 <li>
660 <p><a id="dbcget_DB_MULTIPLE_KEY"></a>
661 <code class="literal">DB_MULTIPLE_KEY</code>
662 </p>
663 <p>
664 Return multiple key and data pairs in the <span class="bold"><strong>data</strong></span> parameter.
665 </p>
666 <p>
667 Key and data pairs, starting at the current cursor position, are
668 entered into the buffer. Subsequent calls with both the DB_NEXT and
669 DB_MULTIPLE_KEY flags specified will return additional key and data
670 pairs or
671 <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_NOTFOUND" class="olink">DB_NOTFOUND</a>
672 if there are no additional key and data items to return.
673 </p>
674 <p>
675 In the case of Btree, Hash or Heap databases, the multiple key and data
676 pairs can be iterated over using the
677 <span>
678 <a class="xref" href="DB_MULTIPLE_KEY_NEXT.html" title="DB_MULTIPLE_KEY_NEXT">DB_MULTIPLE_KEY_NEXT</a> macro.
679 </span>
680
681 </p>
682 <p>
683 In the case of Queue or Recno databases,
684 the multiple record number and data pairs can be
685 iterated over using the
686 <span>
687 <a class="xref" href="DB_MULTIPLE_RECNO_NEXT.html" title="DB_MULTIPLE_RECNO_NEXT">DB_MULTIPLE_RECNO_NEXT</a> macro.
688 </span>
689
690 </p>
691 <p>
692 The buffer to which the <span class="bold"><strong>data</strong></span>
693 parameter refers must be provided from user memory (see
694 <a class="link" href="dbt.html#dbt_DB_DBT_USERMEM">DB_DBT_USERMEM</a> ).
695 The buffer must be at least as large as the page size of the
696 underlying database, aligned for unsigned integer access, and be a
697 multiple of 1024 bytes in size. If the buffer size is insufficient,
698 then upon return from the call the size field of the <span class="bold"><strong>data</strong></span> parameter will have been set to an
699 estimated buffer size, and the error DB_BUFFER_SMALL is returned.
700 (The size is an estimate as the exact size needed may not be known
701 until all entries are read. It is best to initially provide a
702 relatively large buffer, but applications should be prepared to resize
703 the buffer as necessary and repeatedly call the method.)
704 </p>
705 <p>
706 The DB_MULTIPLE_KEY flag may only be used with the DB_CURRENT,
707 DB_FIRST, DB_GET_BOTH, DB_GET_BOTH_RANGE, DB_NEXT, DB_NEXT_DUP,
708 DB_NEXT_NODUP, DB_SET, DB_SET_RANGE, and DB_SET_RECNO options. The
709 DB_MULTIPLE_KEY flag may not be used when accessing databases made
710 into secondary indices using the
711 <a class="xref" href="dbassociate.html" title="DB-&gt;associate()">DB-&gt;associate()</a> method.
712 </p>
713 </li>
714 <li>
715 <p><a id="dbcget_DB_RMW"></a>
716 <code class="literal">DB_RMW</code>
717 </p>
718 <p>
719 Acquire write locks instead of read locks when doing the read, if
720 locking is configured. Setting this flag can eliminate deadlock
721 during a read-modify-write cycle by acquiring the write lock during
722 the read part of the cycle so that another thread of control acquiring
723 a read lock for the same item, in its own read-modify-write cycle,
724 will not result in deadlock.
725 </p>
726 </li>
727 </ul>
728 </div>
729 </div>
730 </div>
731 <div class="sect2" lang="en" xml:lang="en">
732 <div class="titlepage">
733 <div>
734 <div>
735 <h3 class="title"><a id="idp50983200"></a>Errors</h3>
736 </div>
737 </div>
738 </div>
739 <p>
740 The <code class="methodname">DBcursor-&gt;get()</code> <span>
741 <span>
742 method may fail and return one of the following non-zero errors:
743 </span>
744
745 </span>
746 </p>
747 <div class="sect3" lang="en" xml:lang="en">
748 <div class="titlepage">
749 <div>
750 <div>
751 <h4 class="title"><a id="idp50980824"></a>DB_BUFFER_SMALL</h4>
752 </div>
753 </div>
754 </div>
755 <p>
756 The requested item could not be returned due to undersized buffer.
757 </p>
758 </div>
759 <div class="sect3" lang="en" xml:lang="en">
760 <div class="titlepage">
761 <div>
762 <div>
763 <h4 class="title"><a id="idp50911472"></a>DB_LOCK_DEADLOCK</h4>
764 </div>
765 </div>
766 </div>
767 <p>
768 A transactional database environment operation was selected to resolve
769 a deadlock.
770 </p>
771 </div>
772 <div class="sect3" lang="en" xml:lang="en">
773 <div class="titlepage">
774 <div>
775 <div>
776 <h4 class="title"><a id="idp50983328"></a>DB_LOCK_NOTGRANTED</h4>
777 </div>
778 </div>
779 </div>
780 <p>
781 A Berkeley DB Concurrent Data Store database environment configured
782 for lock timeouts was unable to grant a lock in the allowed time.
783 </p>
784 <p>
785 You attempted to open a database handle that is configured
786 for no waiting exclusive locking, but the exclusive lock could not be
787 immediately obtained. See
788 <a class="xref" href="dbset_lk_exclusive.html" title="DB-&gt;set_lk_exclusive()">DB-&gt;set_lk_exclusive()</a>
789 for more information.
790 </p>
791 </div>
792 <div class="sect3" lang="en" xml:lang="en">
793 <div class="titlepage">
794 <div>
795 <div>
796 <h4 class="title"><a id="idp50981040"></a> DB_REP_HANDLE_DEAD</h4>
797 </div>
798 </div>
799 </div>
800 <p>
801 When a client synchronizes with the master, it is possible for committed
802 transactions to be rolled back. This invalidates all the database and cursor
803 handles opened in the replication environment. Once this occurs, an attempt to use
804 such a handle will
805
806 return <code class="literal">DB_REP_HANDLE_DEAD</code>.
807 The application will need to discard the handle and open a new one in order to
808 continue processing.
809 </p>
810 </div>
811 <div class="sect3" lang="en" xml:lang="en">
812 <div class="titlepage">
813 <div>
814 <div>
815 <h4 class="title"><a id="idp50982984"></a>DB_REP_LEASE_EXPIRED</h4>
816 </div>
817 </div>
818 </div>
819 <p>
820 The operation failed because the site's replication master lease has expired.
821 </p>
822 </div>
823 <div class="sect3" lang="en" xml:lang="en">
824 <div class="titlepage">
825 <div>
826 <div>
827 <h4 class="title"><a id="idp50935920"></a>DB_REP_LOCKOUT</h4>
828 </div>
829 </div>
830 </div>
831 <p>
832 The operation was blocked by client/master synchronization.
833 </p>
834 </div>
835 <div class="sect3" lang="en" xml:lang="en">
836 <div class="titlepage">
837 <div>
838 <div>
839 <h4 class="title"><a id="idp50895368"></a>DB_SECONDARY_BAD</h4>
840 </div>
841 </div>
842 </div>
843 <p>
844 A secondary index references a nonexistent primary key.
845 </p>
846 </div>
847 <div class="sect3" lang="en" xml:lang="en">
848 <div class="titlepage">
849 <div>
850 <div>
851 <h4 class="title"><a id="idp50882648"></a>EINVAL</h4>
852 </div>
853 </div>
854 </div>
855 <p>
856 If the DB_CURRENT, DB_NEXT_DUP or DB_PREV_DUP flags were
857 specified and the cursor has not been initialized; the
858 <code class="methodname">DBcursor-&gt;pget()</code> method was called with
859 a cursor that does not refer to a secondary index; or if an
860 invalid flag value or parameter was specified.
861 </p>
862 </div>
863 </div>
864 <div class="sect2" lang="en" xml:lang="en">
865 <div class="titlepage">
866 <div>
867 <div>
868 <h3 class="title"><a id="idp50954888"></a>Class</h3>
869 </div>
870 </div>
871 </div>
872 <p>
873 <a class="link" href="dbc.html" title="Chapter 3.  The DBcursor Handle">DBcursor</a>
874 </p>
875 </div>
876 <div class="sect2" lang="en" xml:lang="en">
877 <div class="titlepage">
878 <div>
879 <div>
880 <h3 class="title"><a id="idp50898888"></a>See Also</h3>
881 </div>
882 </div>
883 </div>
884 <p>
885 <a class="xref" href="dbc.html#dbclist" title="Database Cursors and Related Methods">Database Cursors and Related Methods</a>
886 </p>
887 </div>
888 </div>
889 <div class="navfooter">
890 <hr />
891 <table width="100%" summary="Navigation footer">
892 <tr>
893 <td width="40%" align="left"><a accesskey="p" href="dbcdup.html">Prev</a> </td>
894 <td width="20%" align="center">
895 <a accesskey="u" href="dbc.html">Up</a>
896 </td>
897 <td width="40%" align="right"> <a accesskey="n" href="dbcget_priority.html">Next</a></td>
898 </tr>
899 <tr>
900 <td width="40%" align="left" valign="top">DBcursor-&gt;dup() </td>
901 <td width="20%" align="center">
902 <a accesskey="h" href="index.html">Home</a>
903 </td>
904 <td width="40%" align="right" valign="top"> DBcursor-&gt;get_priority()</td>
905 </tr>
906 </table>
907 </div>
908 </body>
909 </html>