Library Version 18.1.40

Db::convert()
Prev | Chapter 2. The Db Handle | Next

## Db::convert()

    #include <db_cxx.h>

    int
    Db::convert(const char *file, u_int32_t lorder);

The `Db::convert()` method converts all of the databases included in the file file to a specified byte order, if necessary. If no conversion is necessary, `Db::convert()` always returns success.

If the database is partitioned, Db::set_partition() must be called before this method in order to convert all database partitions.

Database conversions are done in place and are destructive. For example, if pages need to be allocated and no disk space is available, the database may be left corrupted. Backups should be made before databases are converted.

The `Db::convert()` method is non-atomic when used on a partitioned or sliced database, or a database with multiple queue extent files. If the operation fails, it is possible for the underlying database files to be in an inconsistent state.

The `Db::convert()` method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

### Parameters

#### file

The file parameter is the physical file containing the databases to be converted.

#### lorder

The lorder parameter should represent the byte order as an integer; for example, big endian order is the number 4,321, and little endian order is the number 1,234.

### Environment Variables

If the database was opened within a database environment, the environment variable `DB_HOME` may be used as the path of the database environment home.

`Db::convert()` is affected by any database directory specified using the DbEnv::add_data_dir() method, or by setting the "add_data_dir" string in the environment's DB_CONFIG file.

### Errors

The `Db::convert()` method may fail and throw a DbException exception, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:

#### EINVAL

The database is corrupted or the the database is encrypted but the password is not provided.

### Class

Db

### See Also

Database and Related Methods

Prev | Up | Next
Db::compact() | Home | db_copy