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>DbSequence::get()</title> 7 <link rel="stylesheet" href="apiReference.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 C++ API Reference" /> 10 <link rel="up" href="seq.html" title="Chapter��12.�� The DbSequence Handle" /> 11 <link rel="prev" href="seqclose.html" title="DbSequence::close()" /> 12 <link rel="next" href="seqget_cachesize.html" title="DbSequence::get_cachesize()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbSequence::get()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="seqclose.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��12.�� 23 The DbSequence Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="seqget_cachesize.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="seqget"></a>DbSequence::get()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbSequence::get(DbTxn *txnid, int32_t delta, db_seq_t *retp, u_int32_t flags);</pre> 42 <p> 43 The <code class="methodname">DbSequence::get()</code> method returns the next available element in 44 the sequence and changes the sequence value by <span class="bold"><strong>delta</strong></span>. The value of <span class="bold"><strong>delta</strong></span> must be greater than zero. If there are 45 enough cached values in the sequence handle then they will be 46 returned. Otherwise the next value will be fetched from the database 47 and incremented (decremented) by enough to cover the <span class="bold"><strong>delta</strong></span> and the next batch of cached values. 48 </p> 49 <p> 50 For maximum concurrency a non-zero cache size should be specified 51 prior to opening the sequence handle and 52 <a class="link" href="envset_flags.html#envset_flags_DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> 53 should be specified for each <code class="methodname">DbSequence::get()</code> method call. 54 </p> 55 <p> 56 By default, sequence ranges do not wrap; to cause the sequence to wrap 57 around the beginning or end of its range, specify the 58 <a class="link" href="seqset_flags.html#seqset_flags_DB_SEQ_WRAP">DB_SEQ_WRAP</a> 59 flag to the <a class="xref" href="seqset_flags.html" title="DbSequence::set_flags()">DbSequence::set_flags()</a> 60 method. 61 </p> 62 <p> 63 The <code class="methodname">DbSequence::get()</code> method will return EINVAL if the record in the 64 database is not a valid sequence record, or the sequence has reached 65 the beginning or end of its range and is not configured to wrap. 66 </p> 67 <div class="sect2" lang="en" xml:lang="en"> 68 <div class="titlepage"> 69 <div> 70 <div> 71 <h3 class="title"><a id="id1709500"></a>Parameters</h3> 72 </div> 73 </div> 74 </div> 75 <div class="sect3" lang="en" xml:lang="en"> 76 <div class="titlepage"> 77 <div> 78 <div> 79 <h4 class="title"><a id="id1709522"></a>delta</h4> 80 </div> 81 </div> 82 </div> 83 <p> 84 Specifies the amount to increment or decrement the sequence. 85 </p> 86 </div> 87 <div class="sect3" lang="en" xml:lang="en"> 88 <div class="titlepage"> 89 <div> 90 <div> 91 <h4 class="title"><a id="id1709514"></a>flags</h4> 92 </div> 93 </div> 94 </div> 95 <p> 96 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 97 or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing 98 together one or more of the following values: 99 </p> 100 <div class="itemizedlist"> 101 <ul type="disc"> 102 <li> 103 <p> 104 <code class="literal">DB_TXN_NOSYNC</code> 105 </p> 106 <p> 107 If the operation is implicitly transaction protected (the <span class="bold"><strong>txnid</strong></span> argument is NULL but the operation occurs 108 to a transactional database), do not synchronously flush the log when 109 the transaction commits. 110 </p> 111 </li> 112 </ul> 113 </div> 114 </div> 115 <div class="sect3" lang="en" xml:lang="en"> 116 <div class="titlepage"> 117 <div> 118 <div> 119 <h4 class="title"><a id="id1709478"></a>retp</h4> 120 </div> 121 </div> 122 </div> 123 <p> 124 <span class="bold"><strong>retp</strong></span> points to the memory to hold the 125 return value from the sequence. 126 </p> 127 </div> 128 <div class="sect3" lang="en" xml:lang="en"> 129 <div class="titlepage"> 130 <div> 131 <div> 132 <h4 class="title"><a id="id1709750"></a>txnid</h4> 133 </div> 134 </div> 135 </div> 136 <p> 137 If the operation is part of an application-specified transaction, the 138 <span class="bold"><strong>txnid</strong></span> parameter is a transaction 139 handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>; if the 140 operation is part of a Berkeley DB Concurrent Data Store group, the 141 <span class="bold"><strong>txnid</strong></span> parameter is a handle returned 142 from <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a>; 143 otherwise NULL. If no transaction handle is specified, but the 144 operation occurs in a transactional database, the operation will be 145 implicitly transaction protected. No <span class="bold"><strong>txnid</strong></span> handle may be specified if the sequence 146 handle was opened with a non-zero cache size. 147 </p> 148 <p> 149 If the underlying database handle was opened in a transaction, calling 150 <code class="methodname">DbSequence::get()</code> may result in changes to the sequence object; 151 these changes will be automatically committed in a transaction 152 internal to the Berkeley DB library. If the thread of control calling 153 <code class="methodname">DbSequence::get()</code> has an active transaction, which holds locks on 154 the same database as the one in which the sequence object is stored, 155 it is possible for a thread of control calling <code class="methodname">DbSequence::get()</code> to 156 self-deadlock because the active transaction's locks conflict with the 157 internal transaction's locks. For this reason, it is often preferable 158 for sequence objects to be stored in their own database. 159 </p> 160 </div> 161 </div> 162 <div class="sect2" lang="en" xml:lang="en"> 163 <div class="titlepage"> 164 <div> 165 <div> 166 <h3 class="title"><a id="id1709820"></a>Class</h3> 167 </div> 168 </div> 169 </div> 170 <p> 171 <a class="link" href="seq.html" title="Chapter��12.�� The DbSequence Handle">DbSequence</a> 172 </p> 173 </div> 174 <div class="sect2" lang="en" xml:lang="en"> 175 <div class="titlepage"> 176 <div> 177 <div> 178 <h3 class="title"><a id="id1709664"></a>See Also</h3> 179 </div> 180 </div> 181 </div> 182 <p> 183 <a class="xref" href="seq.html#seqlist" title="Sequences and Related Methods">Sequences and Related Methods</a> 184 </p> 185 </div> 186 </div> 187 <div class="navfooter"> 188 <hr /> 189 <table width="100%" summary="Navigation footer"> 190 <tr> 191 <td width="40%" align="left"><a accesskey="p" href="seqclose.html">Prev</a>��</td> 192 <td width="20%" align="center"> 193 <a accesskey="u" href="seq.html">Up</a> 194 </td> 195 <td width="40%" align="right">��<a accesskey="n" href="seqget_cachesize.html">Next</a></td> 196 </tr> 197 <tr> 198 <td width="40%" align="left" valign="top">DbSequence::close()��</td> 199 <td width="20%" align="center"> 200 <a accesskey="h" href="index.html">Home</a> 201 </td> 202 <td width="40%" align="right" valign="top">��DbSequence::get_cachesize()</td> 203 </tr> 204 </table> 205 </div> 206 </body> 207</html> 208