1<!--$Id: seq_get.so,v 1.11 2005/08/09 14:23:30 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: DbSequence::get</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<table width="100%"><tr valign=top> 12<td> 13<b>DbSequence::get</b> 14</td> 15<td align=right> 16<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> 17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbSequence::get(DbTxn *txnid, int32_t delta, db_seq_t *retp, u_int32_t flags); 26</pre></b> 27<hr size=1 noshade> 28<b>Description: DbSequence::get</b> 29<p>The DbSequence::get method returns the next available element in the sequence 30and changes the sequence value by <b>delta</b>. The value of 31<b>delta</b> must be greater than zero. If there are enough cached 32values in the sequence handle then they will be returned. Otherwise the 33next value will be fetched from the database and incremented 34(decremented) by enough to cover the <b>delta</b> and the next batch 35of cached values.</p> 36<p>For maximum concurrency a non-zero cache size should be specified prior 37to opening the sequence handle and <a href="../api_cxx/env_set_flags.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> should be 38specified for each DbSequence::get method call.</p> 39<p>By default, sequence ranges do not wrap; to cause the sequence to wrap 40around the beginning or end of its range, specify the <a href="../api_cxx/seq_set_flags.html#DB_SEQ_WRAP">DB_SEQ_WRAP</a> 41flag to the <a href="../api_cxx/seq_set_flags.html">DbSequence::set_flags</a> method.</p> 42<p>The DbSequence::get method will return EINVAL if the record in the database is not a valid sequence 43record, or the sequence has reached the beginning or end of its range 44and is not configured to wrap. 45</p> 46<b>Parameters</b> <br> 47 <b>delta</b><ul compact><li>Specifies the amount to increment or decrement the sequence.</ul> 48 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one 49or more of the following values: 50<br> 51<b><a name="DB_TXN_NOSYNC">DB_TXN_NOSYNC</a></b><ul compact><li>If the operation is implicitly transaction protected (the <b>txnid</b> 52argument is NULL but the operation occurs to a transactional database), 53do not synchronously flush the log when the transaction commits.</ul> 54<br></ul> 55 <b>retp</b><ul compact><li><b>retp</b> points to the memory to hold the return value from 56the sequence.</ul> 57 <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the 58<b>txnid</b> parameter is a transaction handle returned from 59<a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>; if the operation is part of a Berkeley DB Concurrent Data Store group, the 60<b>txnid</b> parameter is a handle returned from 61<a href="../api_cxx/env_cdsgroup_begin.html">DbEnv::cdsgroup_begin</a>; otherwise NULL. 62If no transaction handle is 63specified, but the 64operation occurs in a transactional 65database, 66the operation will be implicitly transaction protected. 67No <b>txnid</b> handle may be specified if the sequence handle was 68opened with a non-zero cache size. 69<p>If the underlying database handle was opened in a transaction, calling 70DbSequence::get may result in changes to the sequence object; these 71changes will be automatically committed in a transaction internal to the 72Berkeley DB library. If the thread of control calling DbSequence::get has 73an active transaction, which holds locks on the same database as the 74one in which the sequence object is stored, it is possible for a thread 75of control calling DbSequence::get to self-deadlock because the active 76transaction's locks conflict with the internal transaction's locks. 77For this reason, it is often preferable for sequence objects to be 78stored in their own database.</p></ul> 79<br> 80<hr size=1 noshade> 81<br><b>Class</b> 82<a href="../api_cxx/seq_class.html">DbSequence</a> 83<br><b>See Also</b> 84<a href="../api_cxx/seq_list.html">Sequences and Related Methods</a> 85</tt> 86<table width="100%"><tr><td><br></td><td align=right> 87<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 88</td></tr></table> 89<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 90</body> 91</html> 92