| 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>Storing records</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="am.html" title="Chapter 3. Access Method Operations" /> |
| 11 | <link rel="prev" href="am_get.html" title="Retrieving records" /> |
| 12 | <link rel="next" href="am_delete.html" title="Deleting records" /> |
| 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">Storing records</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="am_get.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 3. |
| 26 | Access Method Operations |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="am_delete.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="am_put"></a>Storing records</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p> |
| 42 | The <a href="../api_reference/C/dbput.html" class="olink">DB->put()</a> method stores records into the database. In general, |
| 43 | <a href="../api_reference/C/dbput.html" class="olink">DB->put()</a> takes a key and stores the associated data into the |
| 44 | database. |
| 45 | </p> |
| 46 | <p> |
| 47 | There are a few flags that you can set to customize storage: |
| 48 | </p> |
| 49 | <div class="variablelist"> |
| 50 | <dl> |
| 51 | <dt> |
| 52 | <span class="term"> |
| 53 | <a href="../api_reference/C/dbput.html#dbput_DB_APPEND" class="olink">DB_APPEND</a> |
| 54 | </span> |
| 55 | </dt> |
| 56 | <dd> |
| 57 | Simply append the data to the end of the database, treating |
| 58 | the database much like a simple log. This flag is only |
| 59 | valid for the Heap, Queue and Recno access methods. |
| 60 | This flag is required if you are creating a new record in a Heap |
| 61 | database. |
| 62 | </dd> |
| 63 | <dt> |
| 64 | <span class="term"> |
| 65 | <a href="../api_reference/C/dbput.html#put_DB_NOOVERWRITE" class="olink">DB_NOOVERWRITE</a> |
| 66 | </span> |
| 67 | </dt> |
| 68 | <dd> |
| 69 | Only store the data item if the key does not already appear |
| 70 | in the database. |
| 71 | </dd> |
| 72 | </dl> |
| 73 | </div> |
| 74 | <p> |
| 75 | If the database has been configured to support duplicate records, |
| 76 | the <a href="../api_reference/C/dbput.html" class="olink">DB->put()</a> method will add the new data value at the end of the |
| 77 | duplicate set. If the database supports sorted duplicates, the new |
| 78 | data value is inserted at the correct sorted location. |
| 79 | </p> |
| 80 | <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 81 | <h3 class="title">Note</h3> |
| 82 | <p> |
| 83 | If you are using the Heap access method and you are creating a |
| 84 | new record in the database, then the key that you provide to |
| 85 | the <a href="../api_reference/C/dbput.html" class="olink">DB->put()</a> method should be empty. The <a href="../api_reference/C/dbput.html" class="olink">DB->put()</a> method will |
| 86 | return the record's ID (RID) in the key. The RID is |
| 87 | automatically created for you when Heap database records are |
| 88 | created. |
| 89 | </p> |
| 90 | </div> |
| 91 | </div> |
| 92 | <div class="navfooter"> |
| 93 | <hr /> |
| 94 | <table width="100%" summary="Navigation footer"> |
| 95 | <tr> |
| 96 | <td width="40%" align="left"><a accesskey="p" href="am_get.html">Prev</a> </td> |
| 97 | <td width="20%" align="center"> |
| 98 | <a accesskey="u" href="am.html">Up</a> |
| 99 | </td> |
| 100 | <td width="40%" align="right"> <a accesskey="n" href="am_delete.html">Next</a></td> |
| 101 | </tr> |
| 102 | <tr> |
| 103 | <td width="40%" align="left" valign="top">Retrieving records </td> |
| 104 | <td width="20%" align="center"> |
| 105 | <a accesskey="h" href="index.html">Home</a> |
| 106 | </td> |
| 107 | <td width="40%" align="right" valign="top"> Deleting records</td> |
| 108 | </tr> |
| 109 | </table> |
| 110 | </div> |
| 111 | </body> |
| 112 | </html> |