<!--$Id: using.so,v 11.9 2004/11/03 16:38:07 bostic Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Using Berkeley DB with Tcl</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <a name="2"><!--meow--></a> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Tcl API</dl></h3></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> </td></tr></table> <p> <h3 align=center>Using Berkeley DB with Tcl</h3> <p>All commands in the Berkeley DB Tcl interface are in the following form:</p> <blockquote><pre>command_handle operation options</pre></blockquote> <p>The <i>command handle</i> is <b>berkdb</b> or one of the additional commands that may be created. The <i>operation</i> is what you want to do to that handle, and the <i>options</i> apply to the operation. Commands that get created on behalf of the application have their own sets of operations. Generally, any calls in DB that result in new object handles will translate into a new command handle in Tcl. Then, the user can access the operations of the handle via the new Tcl command handle.</p> <p>Newly created commands are named with an abbreviated form of their objects, followed by a number. Some created commands are subcommands of other created commands and will be the first command, followed by a period (.), and then followed by the new subcommand. For example, suppose that you have a database already existing called my_data.db. The following example shows the commands created when you open the database and when you open a cursor:</p> <blockquote><pre># First open the database and get a database command handle % berkdb open my_data.db db0 #Get some data from that database % db0 get my_key {{my_key my_data0}{my_key my_data1}} #Open a cursor in this database, get a new cursor handle % db0 cursor db0.c0 #Get the first data from the cursor % db0.c0 get -first {{first_key first_data}}</pre></blockquote> <p>All commands in the library support a special option <b>-?</b> that will list the correct operations for a command or the correct options.</p> <p>A list of commands and operations can be found in the <a href="../../api_tcl/api_tcl.html">Tcl Interface</a> documentation.</p> <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> </td></tr></table> <p><font size=1>Copyright (c) 1996,2007 Oracle. All rights reserved.</font> </body> </html>