Library Version 11.2.5.2

DB_SEQUENCE->open()
Prev | Chapter 11. The DB_SEQUENCE Handle | Next

## DB_SEQUENCE->open()

    #include <db.h>

    int
    DB_SEQUENCE->open(DB_SEQUENCE *seq, DB_TXN *txnid, DBT *key,
                      u_int32_t flags);

The `DB_SEQUENCE->open()` method opens the sequence represented by the key. The key must be compatible with the underlying database specified in the corresponding call to db_sequence_create.

The `DB_SEQUENCE->open()` method returns a non-zero error value on failure and 0 on success.

### Parameters

#### key

The key specifies which record in the database stores the persistent sequence data.

#### flags

The flags parameter must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

- `DB_CREATE`

  Create the sequence. If the sequence does not already exist and the `DB_CREATE` flag is not specified, the `DB_SEQUENCE->open()` method will fail.

- `DB_EXCL`

  Return an error if the sequence already exists. This flag is only meaningful when specified with the `DB_CREATE` flag.

- `DB_THREAD`

  Cause the DB_SEQUENCE handle returned by `DB_SEQUENCE->open()` to be free-threaded; that is, usable by multiple threads within a single address space. Note that if multiple threads create multiple sequences using the same database handle that handle must have been opened specifying this flag.

#### txnid

If the operation is part of an application-specified transaction, the txnid parameter is a transaction handle returned from DB_ENV->txn_begin(); if the operation is part of a Berkeley DB Concurrent Data Store group, the txnid parameter is a handle returned from DB_ENV->cdsgroup_begin(); otherwise NULL. If no transaction handle is specified, but the operation occurs in a transactional database, the operation will be implicitly transaction protected. Transactionally protected operations on a DB_SEQUENCE handle require the DB_SEQUENCE handle itself be transactionally protected during its open if the open creates the sequence.

### Class

DB_SEQUENCE

### See Also

Sequences and Related Methods

Prev | Up | Next
DB_SEQUENCE->initial_value() | Home | DB_SEQUENCE->remove()