<?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>