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
Description
The dbcget command returns a list of {key value} pairs, except in
the case of the -get_recno and -join_item options. In
the case of the -get_recno option, dbcget returns a list
of the record number. In the case of the -join_item option,
dbcget returns a list containing the joined key.
The options are as follows:
-current
Return the key/data pair currently referenced by the cursor.
If the cursor key/data pair was deleted, dbcget will return an
empty list.
-first
The cursor is set to reference 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.
If the database is a Queue or Recno database, dbcget using the
-first option will skip any keys that exist but were never
explicitly created by the application or were created and later deleted.
If the database is empty, dbcget will return an empty list.
-last
The cursor is set to reference 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.
If the database is a Queue or Recno database, dbcget using the
-last option will skip any keys that exist but were never
explicitly created by the application or were created and later deleted.
If the database is empty, dbcget will return an empty list.
-next
If the cursor is not yet initialized, the -next option is
identical to -first.
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.
If the database is a Queue or Recno database, dbcget using the
-next option will skip any keys that exist but were never
explicitly created by the application or were created and later deleted.
If the cursor is already on the last record in the database, dbcget
will return an empty list.
-nextdup
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, dbcget will return
an empty list.
-nextnodup
If the cursor is not yet initialized, the -nextnodup option is
identical to -first.
Otherwise, the cursor is moved to the next non-duplicate
key/data pair of the database, and that pair is returned.
If no non-duplicate key/data pairs occur after the cursor
position in the database, dbcget will return an empty list.
-prev
If the cursor is not yet initialized, -prev is identical to
-last.
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.
If the database is a Queue or Recno database, dbcget using the
-prev flag will skip any keys that exist but were never explicitly
created by the application or were created and later deleted.
If the cursor is already on the first record in the database,
dbcget will return an empty list.
-prevnodup
If the cursor is not yet initialized, the -prevnodup option is
identical to -last.
Otherwise, the cursor is moved to the previous non-duplicate
key/data pair of the database, and that pair is returned.
If no non-duplicate key/data pairs occur before the cursor
position in the database, dbcget will return an empty list.
-set
Move the cursor to the specified key/data pair of the database, and return
the datum associated with the given key.
In the presence of duplicate key values, dbcget will return the
first data item for the given key.
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,
dbcget will return an empty list.
If no matching keys are found, dbcget will return an empty list.
-set_range
The -set_range option is identical to the -set 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.
-get_both
The -get_both option is identical to the -set option,
except that both the key and the data arguments must be matched by the
key and data item in the database.
For -get_both to be specified, the underlying database must be of
type Btree or Hash.
-set_recno
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.
For the -set_recno option to be specified, the underlying database
must be of type Btree and it must have been created with the -recnum
option.
-get_recno
Return a list of the record number associated with the current cursor
position. No key argument should be specified.
For -get_recno to be specified, the underlying database must be
of type Btree and it must have been created with the -recnum
option.
-join_item
Do not use the data value found in all of 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.
For -join_item to be specified, the cursor must have been created
by the dbjoin command.
-partial {offset length}
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 the existing bytes or 0 bytes are
returned.
-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.
If a key is specified, and
if the underlying database is a Queue or Recno database, then 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.
In the normal error case of attempting to retrieve a key that does not
exist an empty list is returned.