db_result_t db_add_field ( db_t  hdb,
const db_objname_t table,
const db_fielddef_t field_def 
)

Add a field to an existing table.

Parameters:
hdb Database handle.
table Table name.
field_def Field configuration. A field name must start with a letter and can be followed by one or more letters, numbers, or underscores.
Returns:
On failure, one of the following error codes is set:
  • DB_EINVAL Caused by: invalid database handle, table is null, field configuration is null.
  • DB_ENAME Invalid field name.
  • DB_EBINDSIZE Invalid bind size. Datatype and size dont match.
  • DB_ETABLE Table error. Field size=0.
  • DB_EFIELD Caused by: invalid name, index field can not be blob type.
  • DB_EDUPLICATEFIELDS Can not create duplicate fields.
  • DB_EINDEX Index error. Two indexes are eqivalent.
  • 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_rename_field, db_update_field, db_drop_field,
get_db_error, clear_db_error, Error Handling


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