1<!--$Id: dbc_get.so,v 11.22 2004/12/02 18:21:08 bostic Exp $--> 2<!--$Id: m4.tcl,v 11.28 2004/12/16 19:13:05 bostic Exp $--> 3<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 4<!--See the file LICENSE for redistribution information.--> 5<html> 6<head> 7<title>Berkeley DB: db get</title> 8<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 9<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 10</head> 11<body bgcolor=white> 12<table width="100%"><tr valign=top> 13<td> 14<b><i>dbc</i> <b>get</b></b> 15</td> 16<td align=right> 17<a href="../api_tcl/api_tcl.html"><img src="../images/api.gif" alt="API"></a> 18<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 19</tr></table> 20<hr size=1 noshade> 21<tt> 22<b><pre>dbc get 23 [-current] 24 [-first] 25 [-get_recno] 26 [-join_item] 27 [-last] 28 [-next] 29 [-nextdup] 30 [-nextnodup] 31 [-partial {offset length}] 32 [-prev] 33 [-prevnodup] 34 [-rmw] 35dbc get 36 [-partial {offset length}] 37 [-rmw] 38 [-set] 39 [-set_range] 40 [-set_recno] 41 key 42dbc get 43 -get_both 44 [-partial {offset length}] 45 [-rmw] 46 key data 47</pre></b> 48<b>Description(db get)</b> 49<p>The <i>dbc</i> <b>get</b> command returns a list of {key value} pairs, except in 50the case of the <b>-get_recno</b> and <b>-join_item</b> options. In 51the case of the <b>-get_recno</b> option, <i>dbc</i> <b>get</b> returns a list 52of the record number. In the case of the <b>-join_item</b> option, 53<i>dbc</i> <b>get</b> returns a list containing the joined key.</p> 54<p>The options are as follows:</p> 55<br> 56<b>-current</b><ul compact><li>Return the key/data pair to which the cursor currently refers. 57<p>If the cursor key/data pair was deleted, <i>dbc</i> <b>get</b> will return an 58empty list.</p></ul> 59<b>-first</b><ul compact><li>The cursor is set to refer to the first key/data pair of the database, and 60that pair is returned. In the presence of duplicate key values, the first 61data item in the set of duplicates is returned. 62<p>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the 63<b>-first</b> option will skip any keys that exist but were never 64explicitly created by the application, or were created and later deleted.</p> 65<p>If the database is empty, <i>dbc</i> <b>get</b> will return an empty list.</p></ul> 66<b>-last</b><ul compact><li>The cursor is set to refer to the last key/data pair of the database, and 67that pair is returned. In the presence of duplicate key values, the last 68data item in the set of duplicates is returned. 69<p>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the 70<b>-last</b> option will skip any keys that exist but were never 71explicitly created by the application, or were created and later deleted.</p> 72<p>If the database is empty, <i>dbc</i> <b>get</b> will return an empty list.</p></ul> 73<b>-next</b><ul compact><li>If the cursor is not yet initialized, the <b>-next</b> option is 74identical to <b>-first</b>. 75<p>Otherwise, the cursor is moved to the next key/data pair of the database, 76and that pair is returned. In the presence of duplicate key values, the 77value of the key may not change.</p> 78<p>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the 79<b>-next</b> option will skip any keys that exist but were never 80explicitly created by the application, or were created and later deleted.</p> 81<p>If the cursor is already on the last record in the database, <i>dbc</i> <b>get</b> 82will return an empty list.</p></ul> 83<b>-nextdup</b><ul compact><li>If the next key/data pair of the database is a duplicate record for the 84current key/data pair, the cursor is moved to the next key/data pair of the 85database, and that pair is returned. Otherwise, <i>dbc</i> <b>get</b> will return 86an empty list.</ul> 87<b>-nextnodup</b><ul compact><li>If the cursor is not yet initialized, the <b>-nextnodup</b> option is 88identical to <b>-first</b>. 89<p>Otherwise, the cursor is moved to the next non-duplicate 90key/data pair of the database, and that pair is returned.</p> 91<p>If no non-duplicate key/data pairs occur after the cursor 92position in the database, <i>dbc</i> <b>get</b> will return an empty list.</p></ul> 93<b>-prev</b><ul compact><li>If the cursor is not yet initialized, <b>-prev</b> is identical to 94<b>-last</b>. 95<p>Otherwise, the cursor is moved to the previous key/data pair of the 96database, and that pair is returned. In the presence of duplicate key 97values, the value of the key may not change.</p> 98<p>If the database is a Queue or Recno database, <i>dbc</i> <b>get</b> using the 99<b>-prev</b> flag will skip any keys that exist but were never explicitly 100created by the application, or were created and later deleted.</p> 101<p>If the cursor is already on the first record in the database, 102<i>dbc</i> <b>get</b> will return an empty list.</p></ul> 103<b>-prevnodup</b><ul compact><li>If the cursor is not yet initialized, the <b>-prevnodup</b> option is 104identical to <b>-last</b>. 105<p>Otherwise, the cursor is moved to the previous non-duplicate 106key/data pair of the database, and that pair is returned.</p> 107<p>If no non-duplicate key/data pairs occur before the cursor 108position in the database, <i>dbc</i> <b>get</b> will return an empty list.</p></ul> 109<b>-set</b><ul compact><li>Move the cursor to the specified key/data pair of the database, and return 110the datum associated with the given key. 111<p>In the presence of duplicate key values, <i>dbc</i> <b>get</b> will return the 112first data item for the given key.</p> 113<p>If the database is a Queue or Recno database and the requested key exists, 114but was never explicitly created by the application or was later deleted, 115<i>dbc</i> <b>get</b> will return an empty list.</p> 116<p>If no matching keys are found, <i>dbc</i> <b>get</b> will return an empty list.</p></ul> 117<b>-set_range</b><ul compact><li>The <b>-set_range</b> option is identical to the <b>-set</b> option, 118except that the key is returned as well as the data item, and, in the case 119of the Btree access method, the returned key/data pair is the smallest 120key greater than or equal to the specified key (as determined by the 121comparison function), permitting partial key matches and range searches.</ul> 122<b>-get_both</b><ul compact><li>The <b>-get_both</b> option is identical to the <b>-set</b> option, 123except that both the key and the data arguments must be matched by the 124key and data item in the database. 125<p>For <b>-get_both</b> to be specified, the underlying database must be of 126type Btree or Hash.</p></ul> 127<b>-set_recno</b><ul compact><li>Move the cursor to the specific numbered record of the database, and 128return the associated key/data pair. The key 129must be a record number. 130<p>For the <b>-set_recno</b> option to be specified, the underlying database 131must be of type Btree, and it must have been created with the <b>-recnum</b> 132option.</p></ul> 133<b>-get_recno</b><ul compact><li>Return a list of the record number associated with the current cursor 134position. No key argument should be specified. 135<p>For <b>-get_recno</b> to be specified, the underlying database must be 136of type Btree, and it must have been created with the <b>-recnum</b> 137option.</p></ul> 138<b>-join_item</b><ul compact><li>Do not use the data value found in all the cursors as a lookup key for 139the primary database, but simply return it in the key parameter instead. 140The data parameter is left unchanged. 141<p>For <b>-join_item</b> to be specified, the cursor must have been created 142by the <i>db</i> <b>join</b> command.</p></ul> 143<b>-partial {offset length}</b><ul compact><li>The <b>dlen</b> bytes starting <b>doff</b> bytes from the beginning 144of the retrieved data record are returned as if they comprised the 145entire record. If any or all of the specified bytes do not exist in 146the record, the command is successful and any existing bytes are 147returned.</ul> 148<b>-rmw</b><ul compact><li>Acquire write locks instead of read locks when doing the retrieval. Setting 149this flag may decrease the likelihood of deadlock during a read-modify-write 150cycle by immediately acquiring the write lock during the read part of the 151cycle so that another thread of control acquiring a read lock for the same 152item, in its own read-modify-write cycle, will not result in deadlock.</ul> 153<br> 154<p>If a key is specified, and if the underlying database is a Queue or 155Recno database, the given key will be interpreted by Tcl as an integer. 156For all other database types, the key is interpreted by Tcl as a byte 157array, unless indicated by a given option.</p> 158<p>In the normal error case of attempting to retrieve a key that does not 159exist an empty list is returned.</p> 160<p>In the case of error, a Tcl error is thrown.</p> 161</tt> 162<table width="100%"><tr><td><br></td><td align=right> 163<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> 164</td></tr></table> 165<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 166</body> 167</html> 168