### db get |

`

###

    db get
    	[-consume]
    	[-consume_wait]
    	[-glob]
    	[-partial {doff dlen}]
    	[-recno]
    	[-rmw]
    	[-txn txnid]
    	key
    db get
    	-get_both
    	[-partial {doff dlen}]
    	[-rmw]
    	[-txn txnid]
    	key data

### Description(db get)

The db get command returns key/data pairs from the database.

In the presence of duplicate key values, db get will return all duplicate items. Duplicates are sorted by insert order except where this order has been overridden by cursor operations.

The options are as follows:

-consume
  Return the record number and data from the available record closest to the head of the queue, and delete the record. The cursor will be positioned on the deleted record. A record is available if it is not deleted and is not currently locked. The underlying database must be of type Queue for -consume to be specified.
-consume_wait
  The same as the -consume flag except that if the Queue database is empty, the thread of control will wait until there is data in the queue before returning. The underlying database must be of type Queue for -consume_wait to be specified.
-get_both key data
  Retrieve the key/data pair only if both the key and data match the arguments.
-glob
  Return all keys matching the given key, where the key is a simple wildcard pattern. Where it is used, it replaces the use of the key with the given pattern of a set of keys. Any characters after the wildcard character are ignored. For example, in a database of last names, the command "db0 get Jones" will return all occurrences of "Jones" in the database, and the command "db0 get -glob Jo*" will return both "Jones" and "Johnson" from the database. The command "db0 get -glob *" will return all of the key/data pairs in the database. This option only works on databases using the Btree access method.
-partial {doff dlen}
  The dlen bytes starting doff 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.
-recno
  Retrieve the specified numbered key/data pair from a database. For -recno to be specified, the specified key must be a record number; and the underlying database must be of type Recno or Queue, or of type Btree that was created with the -recnum option.
-rmw
  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.

  Because the db get command will not hold locks across Berkeley DB interface calls in nontransactional environments, the -rmw argument to the db get call is only meaningful in the presence of transactions.

-txn txnid
  If the operation is part of an application-specified transaction, the txnid parameter is a transaction handle returned from env txn. If no transaction handle is specified, but the operation occurs in a transactional database, the operation will be implicitly transaction protected.

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.

A list of key/data pairs is returned. In the error case that no matching key exists, an empty list is returned. In all other cases, a Tcl error is thrown.

`

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.