1<!--$Id: using.so,v 11.9 2004/11/03 16:38:07 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB Reference Guide: Using Berkeley DB with Tcl</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<a name="2"><!--meow--></a>
12<table width="100%"><tr valign=top>
13<td><b><dl><dt>Berkeley DB Reference Guide:<dd>Tcl API</dl></b></td>
14<td align=right><a href="../tcl/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../tcl/program.html"><img src="../../images/next.gif" alt="Next"></a>
15</td></tr></table>
16<p align=center><b>Using Berkeley DB with Tcl</b></p>
17<p>All commands in the Berkeley DB Tcl interface are in the following form:</p>
18<blockquote><pre>command_handle operation options</pre></blockquote>
19<p>The <i>command handle</i> is <b>berkdb</b> or one of the additional
20commands that may be created. The <i>operation</i> is what you want
21to do to that handle, and the <i>options</i> apply to the operation.
22Commands that get created on behalf of the application have their own sets
23of operations.  Generally, any calls in DB that result in new object
24handles will translate into a new command handle in Tcl. Then, the user
25can access the operations of the handle via the new Tcl command handle.</p>
26<p>Newly created commands are named with an abbreviated form of their
27objects, followed by a number. Some created commands are subcommands of
28other created commands and will be the first command, followed by a
29period (.), and then followed by the new subcommand. For example,
30suppose that you have a database already existing called my_data.db.
31The following example shows the commands created when you open the
32database and when you open a cursor:</p>
33<blockquote><pre># First open the database and get a database command handle
34% berkdb open my_data.db
35db0
36#Get some data from that database
37% db0 get my_key
38{{my_key my_data0}{my_key my_data1}}
39#Open a cursor in this database, get a new cursor handle
40% db0 cursor
41db0.c0
42#Get the first data from the cursor
43% db0.c0 get -first
44{{first_key first_data}}</pre></blockquote>
45<p>All commands in the library support a special option <b>-?</b> that will
46list the correct operations for a command or the correct options.</p>
47<p>A list of commands and operations can be found in the
48<a href="../../api_tcl/api_tcl.html">Tcl Interface</a> documentation.</p>
49<table width="100%"><tr><td><br></td><td align=right><a href="../tcl/intro.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../tcl/program.html"><img src="../../images/next.gif" alt="Next"></a>
50</td></tr></table>
51<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
52</body>
53</html>
54