| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Using Berkeley DB with Tcl</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="tcl.html" title="Chapter 21. Berkeley DB Extensions: Tcl" /> |
| 11 | <link rel="prev" href="tcl.html" title="Chapter 21. Berkeley DB Extensions: Tcl" /> |
| 12 | <link rel="next" href="tcl_program.html" title="Tcl API programming notes" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Using Berkeley DB with Tcl</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="tcl.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 21. |
| 26 | Berkeley DB Extensions: Tcl |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="tcl_program.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="tcl_using"></a>Using Berkeley DB with Tcl</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>All commands in the Berkeley DB Tcl interface are in the following form:</p> |
| 42 | <pre class="programlisting">command_handle operation options</pre> |
| 43 | <p>The <span class="emphasis"><em>command handle</em></span> is <span class="bold"><strong>berkdb</strong></span> or one of the additional |
| 44 | commands that may be created. The <span class="emphasis"><em>operation</em></span> is what you want |
| 45 | to do to that handle, and the <span class="emphasis"><em>options</em></span> apply to the operation. |
| 46 | Commands that get created on behalf of the application have their own sets |
| 47 | of operations. Generally, any calls in DB that result in new object |
| 48 | handles will translate into a new command handle in Tcl. Then, the user |
| 49 | can access the operations of the handle via the new Tcl command handle.</p> |
| 50 | <p>Newly created commands are named with an abbreviated form of their |
| 51 | objects, followed by a number. Some created commands are subcommands of |
| 52 | other created commands and will be the first command, followed by a |
| 53 | period (.), and then followed by the new subcommand. For example, |
| 54 | suppose that you have a database already existing called my_data.db. |
| 55 | The following example shows the commands created when you open the |
| 56 | database and when you open a cursor:</p> |
| 57 | <pre class="programlisting"># First open the database and get a database command handle |
| 58 | % berkdb open my_data.db |
| 59 | db0 |
| 60 | #Get some data from that database |
| 61 | % db0 get my_key |
| 62 | {{my_key my_data0}{my_key my_data1}} |
| 63 | #Open a cursor in this database, get a new cursor handle |
| 64 | % db0 cursor |
| 65 | db0.c0 |
| 66 | #Get the first data from the cursor |
| 67 | % db0.c0 get -first |
| 68 | {{first_key first_data}}</pre> |
| 69 | <p>All commands in the library support a special option <span class="bold"><strong>-?</strong></span> that will |
| 70 | list the correct operations for a command or the correct options.</p> |
| 71 | <p>A list of commands and operations can be found in the |
| 72 | <a href="../api_reference/TCL/index.html" class="olink">Tcl API</a> documentation.</p> |
| 73 | </div> |
| 74 | <div class="navfooter"> |
| 75 | <hr /> |
| 76 | <table width="100%" summary="Navigation footer"> |
| 77 | <tr> |
| 78 | <td width="40%" align="left"><a accesskey="p" href="tcl.html">Prev</a> </td> |
| 79 | <td width="20%" align="center"> |
| 80 | <a accesskey="u" href="tcl.html">Up</a> |
| 81 | </td> |
| 82 | <td width="40%" align="right"> <a accesskey="n" href="tcl_program.html">Next</a></td> |
| 83 | </tr> |
| 84 | <tr> |
| 85 | <td width="40%" align="left" valign="top">Chapter 21. |
| 86 | Berkeley DB Extensions: Tcl |
| 87 | </td> |
| 88 | <td width="20%" align="center"> |
| 89 | <a accesskey="h" href="index.html">Home</a> |
| 90 | </td> |
| 91 | <td width="40%" align="right" valign="top"> Tcl API programming notes</td> |
| 92 | </tr> |
| 93 | </table> |
| 94 | </div> |
| 95 | </body> |
| 96 | </html> |