db_result_t db_create_index ( db_t  hdb,
const db_objname_t table,
const db_objname_t index,
const db_indexdef_t param 
)

Create an index on a table using an index schema definition.

Parameters:
hdb Database handle.
table Table name. A name must start with a letter and can be followed by one or more letters, numbers, or underscores.
index Index name. A name must start with a letter and can be followed by one or more letters, numbers, or underscores.
param Index configuration.
Returns:
On failure, one of the following error codes is set:
  • DB_EINVAL Caused by: invalid database handle, table is null, index name is null, index configuration is null .
  • DB_ENAME Invalid name.
  • DB_EFIELD Caused by: number of fields in index definition <=0, index field can not be of blob type.
  • DB_EINDEX Index error. Can not have duplicate indexes.
  • DB_ELOCKED Table is locked by cursor or concurrent transaction.
  • DB_ETXSTATE A transaction is active.

A table can only be altered or dropped when there is no active transaction. If a transaction has been started, db_commit_tx or db_abort_tx must be used before db_drop_table can be called.

See also:
db_drop_index, db_describe_index,
get_db_error, clear_db_error, Error Handling


Copyright © 2005-2008 ITTIA®. All rights reserved.