summaryrefslogtreecommitdiff
path: root/db/docs/api_tcl/dbc_get.html
blob: 8093454518b98a23ee8c065ebb4f67486dcaf027 (plain)
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
<!--$Id: dbc_get.so,v 11.21 2002/08/18 21:17:28 bostic Exp $-->
<!--$Id: m4.tcl,v 11.27 2004/09/07 15:37:41 bostic Exp $-->
<!--Copyright 1997-2004 by Sleepycat Software, Inc.-->
<!--All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: db get</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<h3><i>dbc</i> <b>get</b></h3>
</td>
<td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a>
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<h3><pre>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></h3>
<h3>Description(db get)</h3>
<p>The <i>dbc</i> <b>get</b> command returns a list of {key value} pairs, except in
the case of the <b>-get_recno</b> and <b>-join_item</b> options.  In
the case of the <b>-get_recno</b> option, <i>dbc</i> <b>get</b> returns a list
of the record number.  In the case of the <b>-join_item</b> option,
<i>dbc</i> <b>get</b> returns a list containing the joined key.</p>
<p>The options are as follows:</p>
<dl compact>
<dt>-current<dd>Return the key/data pair to which the cursor currently refers.
<p>If the cursor key/data pair was deleted, <i>dbc</i> <b>get</b> will return an
empty list.</p>
<dt>-first<dd>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>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the
<b>-first</b> 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, <i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-last<dd>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>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the
<b>-last</b> 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, <i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-next<dd>If the cursor is not yet initialized, the <b>-next</b> option is
identical to <b>-first</b>.
<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, <i>dbc</i> <b>get</b> using the
<b>-next</b> 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, <i>dbc</i> <b>get</b>
will return an empty list.</p>
<dt>-nextdup<dd>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, <i>dbc</i> <b>get</b> will return
an empty list.
<dt>-nextnodup<dd>If the cursor is not yet initialized, the <b>-nextnodup</b> option is
identical to <b>-first</b>.
<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, <i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-prev<dd>If the cursor is not yet initialized, <b>-prev</b> is identical to
<b>-last</b>.
<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, <i>dbc</i> <b>get</b> using the
<b>-prev</b> 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,
<i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-prevnodup<dd>If the cursor is not yet initialized, the <b>-prevnodup</b> option is
identical to <b>-last</b>.
<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, <i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-set<dd>Move the cursor to the specified key/data pair of the database, and return
the datum associated with the given key.
<p>In the presence of duplicate key values, <i>dbc</i> <b>get</b> 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,
<i>dbc</i> <b>get</b> will return an empty list.</p>
<p>If no matching keys are found, <i>dbc</i> <b>get</b> will return an empty list.</p>
<dt>-set_range<dd>The <b>-set_range</b> option is identical to the <b>-set</b> 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.
<dt>-get_both<dd>The <b>-get_both</b> option is identical to the <b>-set</b> option,
except that both the key and the data arguments must be matched by the
key and data item in the database.
<p>For <b>-get_both</b> to be specified, the underlying database must be of
type Btree or Hash.</p>
<dt>-set_recno<dd>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>For the <b>-set_recno</b> option to be specified, the underlying database
must be of type Btree, and it must have been created with the <b>-recnum</b>
option.</p>
<dt>-get_recno<dd>Return a list of the record number associated with the current cursor
position.  No key argument should be specified.
<p>For <b>-get_recno</b> to be specified, the underlying database must be
of type Btree, and it must have been created with the <b>-recnum</b>
option.</p>
<dt>-join_item<dd>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>For <b>-join_item</b> to be specified, the cursor must have been created
by the <i>db</i> <b>join</b> command.</p>
<dt>-partial {offset length}<dd>The <b>dlen</b> bytes starting <b>doff</b> 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.
<dt>-rmw<dd>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.
</dl>
<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>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1><a href="../sleepycat/legal.html">Copyright (c) 1996-2004</a> <a href="http://www.sleepycat.com">Sleepycat Software, Inc.</a> - All rights reserved.</font>
</body>
</html>