File: dbc_get.html

package info (click to toggle)
db5.3 5.3.28-9%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 163,332 kB
  • sloc: ansic: 448,411; java: 111,824; tcl: 80,544; sh: 44,326; cs: 33,697; cpp: 21,604; perl: 14,557; xml: 10,799; makefile: 4,104; yacc: 1,003; awk: 965; sql: 801; erlang: 342; python: 216; php: 24; asm: 14
file content (404 lines) | stat: -rw-r--r-- 18,464 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>dbc get</title>
    <link rel="stylesheet" href="apiReference.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB TCL API Reference" />
    <link rel="up" href="tclapi.html" title="Chapter 1.  Berkeley DB Tcl APIs" />
    <link rel="prev" href="dbc_dup.html" title="dbc dup" />
    <link rel="next" href="dbc_put.html" title="dbc put" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 11.2.5.3</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center"><span xmlns="http://www.w3.org/1999/xhtml" class="emphasis"><em>dbc</em></span> get</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="dbc_dup.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 1. 
                Berkeley DB Tcl APIs
        </th>
          <td width="20%" align="right"> <a accesskey="n" href="dbc_put.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="dbc_get"></a><span class="emphasis"><em>dbc</em></span> get</h2>
          </div>
        </div>
      </div>
      <pre class="programlisting">dbc get
	[-current]
	[-first]
	[-get_recno]
	[-join_item]
	[-last]
	[-next]
	[-nextdup]
	[-nextnodup]
	[-partial {offset length}]
	[-prev]
	[-prevnodup]
	[-rmw]

dbc get
	[-partial {offset length}]
	[-rmw]
	[-set]
	[-set_range]
	[-set_recno]
	key

dbc get
	-get_both
	[-partial {offset length}]
	[-rmw]
	key data  </pre>
      <p>
         The <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span>
         command returns a list of {key value} pairs, except in the case of the
         <span class="bold"><strong>-get_recno</strong></span> and <span class="bold"><strong>-join_item</strong></span> options.  In the case of the
         <span class="bold"><strong>-get_recno</strong></span> option,
         <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> returns
         a list of the record number.  In the case of the <span class="bold"><strong>-join_item</strong></span> option, <span class="emphasis"><em>dbc</em></span>
         <span class="bold"><strong>get</strong></span> returns a list containing the
         joined key.
    </p>
      <p>
        The options follow, and are grouped by the action they perform.
    </p>
      <p>
        The first group affects the position of the cursor in the database
        without regard for the key or data item.
    </p>
      <div class="itemizedlist">
        <ul type="disc">
          <li>
            <p>
                 <span class="bold"><strong>-current</strong></span> 
            </p>
            <p>
                 Return the key/data pair to which the cursor currently refers.    
             </p>
            <p>
                 If the cursor key/data pair was deleted, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-first</strong></span> 
            </p>
            <p>
                 The cursor is set to refer to the first key/data pair of the database,
                 and that pair is returned. In the presence of duplicate key values,
                 the first data item in the set of duplicates is returned.     
            </p>
            <p>
                 If the database is a Queue or Recno database, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> using the <span class="bold"><strong>-first</strong></span> option will skip any keys that exist but
                 were never explicitly created by the application, or were created and
                 later deleted.
            </p>
            <p>
                 If the database is empty, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-last</strong></span> 
            </p>
            <p>
                 The cursor is set to refer to the last key/data pair of the database,
                 and that pair is returned. In the presence of duplicate key values,
                 the last data item in the set of duplicates is returned.     
             </p>
            <p>
                 If the database is a Queue or Recno database, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> using the <span class="bold"><strong>-last</strong></span> option will skip any keys that exist but
                 were never explicitly created by the application, or were created and
                 later deleted.
            </p>
            <p>
                 If the database is empty, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
                </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-next</strong></span> 
            </p>
            <p>
                 If the cursor is not yet initialized, the <span class="bold"><strong>-next</strong></span> option is identical to <span class="bold"><strong>-first</strong></span>.     
            </p>
            <p>
                 Otherwise, the cursor is moved to the next key/data pair of the
                 database, and that pair is returned. In the presence of duplicate key
                 values, the value of the key may not change.
            </p>
            <p>
                 If the database is a Queue or Recno database, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> using the <span class="bold"><strong>-next</strong></span> option will skip any keys that exist but
                 were never explicitly created by the application, or were created and
                 later deleted.
            </p>
            <p>
                 If the cursor is already on the last record in the database,
                 <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will
                 return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-nextdup</strong></span> 
            </p>
            <p>
                 If the next key/data pair of the database is a duplicate record for
                 the current key/data pair, the cursor is moved to the next key/data
                 pair of the database, and that pair is returned. Otherwise,
                 <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will
                 return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-nextnodup</strong></span> 
            </p>
            <p>
                 If the cursor is not yet initialized, the <span class="bold"><strong>-nextnodup</strong></span> option is identical to <span class="bold"><strong>-first</strong></span>.     
            </p>
            <p>
                 Otherwise, the cursor is moved to the next non-duplicate key/data pair
                 of the database, and that pair is returned.
            </p>
            <p>
                 If no non-duplicate key/data pairs occur after the cursor position in
                 the database, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-prev</strong></span> 
            </p>
            <p>
                 If the cursor is not yet initialized, <span class="bold"><strong>-prev</strong></span> is identical to <span class="bold"><strong>-last</strong></span>.    
            </p>
            <p>
                 Otherwise, the cursor is moved to the previous key/data pair of the
                 database, and that pair is returned. In the presence of duplicate key
                 values, the value of the key may not change.
            </p>
            <p>
                 If the database is a Queue or Recno database, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> using the <span class="bold"><strong>-prev</strong></span> flag will skip any keys that exist but
                 were never explicitly created by the application, or were created and
                 later deleted.
            </p>
            <p>
                 If the cursor is already on the first record in the database,
                 <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will
                 return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-prevnodup</strong></span> 
            </p>
            <p>
                 If the cursor is not yet initialized, the <span class="bold"><strong>-prevnodup</strong></span> option is identical to <span class="bold"><strong>-last</strong></span>.     
            </p>
            <p>
                 Otherwise, the cursor is moved to the previous non-duplicate key/data
                 pair of the database, and that pair is returned.
            </p>
            <p>
                 If no non-duplicate key/data pairs occur before the cursor position in
                 the database, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
          </li>
        </ul>
      </div>
      <p>
                The next group of options are used to move the cursor to a
                location in the database based on characteristics of the
                key and/or data items.
            </p>
      <div class="itemizedlist">
        <ul type="disc">
          <li>
            <p>
                  <span class="bold"><strong>-set</strong></span> 
             </p>
            <p>
                 Move the cursor to the specified key/data pair of the database, and
                 return the datum associated with the given key.     
             </p>
            <p>
                 In the presence of duplicate key values, <span class="emphasis"><em>dbc</em></span>
                 <span class="bold"><strong>get</strong></span> will return the first data item
                 for the given key.
            </p>
            <p>
                 If the database is a Queue or Recno database and the requested key
                 exists, but was never explicitly created by the application or was
                 later deleted, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
            <p>
                 If no matching keys are found, <span class="emphasis"><em>dbc</em></span> <span class="bold"><strong>get</strong></span> will return an empty list.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-set_range</strong></span> 
            </p>
            <p>
                 The <span class="bold"><strong>-set_range</strong></span> option is identical to
                 the <span class="bold"><strong>-set</strong></span> option, except that the key
                 is returned as well as the data item, and, in the case of the Btree
                 access method, the returned key/data pair is the smallest key greater
                 than or equal to the specified key (as determined by the comparison
                 function), permitting partial key matches and range searches.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-get_both</strong></span> 
            </p>
            <p>
                 The <span class="bold"><strong>-get_both</strong></span> option is identical to
                 the <span class="bold"><strong>-set</strong></span> option, except that both the
                 key and the data arguments must be matched by the key and data item in
                 the database.     
            </p>
            <p>
                 For <span class="bold"><strong>-get_both</strong></span> to be specified, the
                 underlying database must be of type Btree or Hash.
 
            </p>
          </li>
        </ul>
      </div>
      <p>
                The last group of options is a general collection of
                operations. Some of these involve positioning the cursor to
                a location in the database based in information other than
                what can be found in the key and/or data items. Others of
                these have to do with the cursor's behavior upon retrieving
                information.
            </p>
      <div class="itemizedlist">
        <ul type="disc">
          <li>
            <p>
                  <span class="bold"><strong>-set_recno</strong></span> 
            </p>
            <p>
                 Move the cursor to the specific numbered record of the database, and
                 return the associated key/data pair. The key must be a record number. 
            </p>
            <p>
                 For the <span class="bold"><strong>-set_recno</strong></span> option to be
                 specified, the underlying database must be of type Btree, and it must
                 have been created with the <span class="bold"><strong>-recnum</strong></span>
                 option.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-get_recno</strong></span> 
            </p>
            <p>
                 Return a list of the record number associated with the current cursor
                 position.  No key argument should be specified.     
            </p>
            <p>
                 For <span class="bold"><strong>-get_recno</strong></span> to be specified, the
                 underlying database must be of type Btree, and it must have been
                 created with the <span class="bold"><strong>-recnum</strong></span> option.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-join_item</strong></span> 
            </p>
            <p>
                 Do not use the data value found in all the cursors as a lookup key for
                 the primary database, but simply return it in the key parameter
                 instead. The data parameter is left unchanged.     
            </p>
            <p>
                 For <span class="bold"><strong>-join_item</strong></span> to be specified, the
                 cursor must have been created by the <span class="emphasis"><em>db</em></span> <span class="bold"><strong>join</strong></span> command.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-partial {offset length}</strong></span> 
            </p>
            <p>
                 The <span class="bold"><strong>dlen</strong></span> bytes starting <span class="bold"><strong>doff</strong></span> bytes from the beginning of the retrieved
                 data record are returned as if they comprised the entire record.  If
                 any or all of the specified bytes do not exist in the record, the
                 command is successful and any existing bytes are returned.
            </p>
          </li>
          <li>
            <p>
                  <span class="bold"><strong>-rmw</strong></span> 
            </p>
            <p>
                 Acquire write locks instead of read locks when doing the retrieval.
                 Setting this flag may decrease the likelihood of deadlock during a
                 read-modify-write cycle by immediately acquiring the write lock during
                 the read part of the cycle so that another thread of control acquiring
                 a read lock for the same item, in its own read-modify-write cycle,
                 will not result in deadlock.
            </p>
          </li>
        </ul>
      </div>
      <p>
         If a key is specified, and if the underlying database is a Queue or
         Recno database, the given key will be interpreted by Tcl as an
         integer. For all other database types, the key is interpreted by Tcl
         as a byte array, unless indicated by a given option.
    </p>
      <p>
         In the normal error case of attempting to retrieve a key that does not
         exist an empty list is returned.
    </p>
      <p>
        In the case of error, a Tcl error is thrown.
    </p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="dbc_dup.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="tclapi.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="dbc_put.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top"><span class="emphasis"><em>dbc</em></span> dup </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> <span class="emphasis"><em>dbc</em></span> put</td>
        </tr>
      </table>
    </div>
  </body>
</html>