File Geodatabase API
FileGDBAPI::Table Class Reference

Provides methods to work with tables, such as querying and modifying both schema and data. More...

Public Member Functions

Schema
fgdbError GetDefinition (std::string &tableDef) const
 Gets the table's definition as an XML document. More...
 
fgdbError GetDocumentation (std::string &documentation) const
 Gets the table's metadata as XML. More...
 
fgdbError SetDocumentation (const std::string &documentation)
 Assigns metadata to the table. More...
 
fgdbError GetFieldInformation (FieldInfo &fieldInfo) const
 Return information about the fields in the table. More...
 
fgdbError GetFields (std::vector< FieldDef > &fieldDefs) const
 Returns an array of FieldDef objects of the table's field collection. More...
 
fgdbError AddField (const std::string &fieldDef)
 Adds a field to the table. More...
 
fgdbError AddField (const FieldDef &fieldDef)
 Adds a field to the table. More...
 
fgdbError AlterField (const std::string &fieldDef)
 Modifies a field in the table. More...
 
fgdbError DeleteField (const std::wstring &fieldName)
 Deletes a field from the table. More...
 
fgdbError GetIndexes (std::vector< std::string > &indexDefs) const
 Returns an XML definition of the table's index collection. More...
 
fgdbError GetIndexes (std::vector< IndexDef > &indexDefs) const
 Returns an array of IndexDef objects of the table's index collection. More...
 
fgdbError AddIndex (const std::string &indexDef)
 Adds an index to the table. More...
 
fgdbError AddIndex (const IndexDef &indexDef)
 Adds an index to the table. More...
 
fgdbError DeleteIndex (const std::wstring &indexName)
 Deletes an index from the table. More...
 
fgdbError CreateSubtype (const std::string &subtypeDef)
 Creates a new subtype to the table. More...
 
fgdbError AlterSubtype (const std::string &subtypeDef)
 Modifies an existing subtype of the table. More...
 
fgdbError DeleteSubtype (const std::wstring &subtypeName)
 Deletes a subtype from the table. More...
 
fgdbError EnableSubtypes (const std::wstring &subtypeFieldName, const std::string &subtypeDef)
 Enables subtypes on a table. More...
 
fgdbError GetDefaultSubtypeCode (int &defaultCode) const
 Returns the default subtype code. More...
 
fgdbError SetDefaultSubtypeCode (int defaultCode)
 Sets the default subtype code. More...
 
fgdbError DisableSubtypes ()
 Drops the table's subtypes. More...
 
Data
fgdbError Search (const std::wstring &subfields, const std::wstring &whereClause, const Envelope &envelope, bool recycling, EnumRows &rows)
 Performs a spatial query (envelope intersects) on the table. More...
 
fgdbError Search (const std::wstring &subfields, const std::wstring &whereClause, bool recycling, EnumRows &rows)
 Performs an attribute query on the table. More...
 
fgdbError CreateRowObject (Row &row)
 Creates a new row in memory for the table. More...
 
fgdbError Insert (Row &row)
 Inserts a newly-created and populated row into the table. More...
 
fgdbError Update (Row &row)
 Updates an existing row in the table. More...
 
fgdbError Delete (Row &row)
 Deletes a row from the table. More...
 
fgdbError IsEditable (bool &isEditable)
 Indicates whether the table should be edited. More...
 
fgdbError GetRowCount (int &rowCount) const
 Returns the number of rows in the table. More...
 
fgdbError GetExtent (Envelope &extent) const
 Returns the extent of the feature class. More...
 
fgdbError SetWriteLock (void)
 Sets a write lock on a table. More...
 
fgdbError FreeWriteLock (void)
 Frees a write lock on a table. More...
 
fgdbError LoadOnlyMode (bool loadOnlyMode)
 Begin or End load only mode. More...
 
Constructors and destructors
 Table ()
 The class constructor.
 
 ~Table ()
 The class destructor.
 

Detailed Description

Provides methods to work with tables, such as querying and modifying both schema and data.

Member Function Documentation

fgdbError FileGDBAPI::Table::GetDefinition ( std::string &  tableDef) const

Gets the table's definition as an XML document.

Parameters
[out]tableDefAn XML document than defines the table's schema.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetDocumentation ( std::string &  documentation) const

Gets the table's metadata as XML.

Parameters
[out]documentationThe table's metadata as XML.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::SetDocumentation ( const std::string &  documentation)

Assigns metadata to the table.

Parameters
[in]documentationAn XML document that will be the table's metadata.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetFieldInformation ( FieldInfo fieldInfo) const

Return information about the fields in the table.

Parameters
[out]fieldInfoThe field information.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetFields ( std::vector< FieldDef > &  fieldDefs) const

Returns an array of FieldDef objects of the table's field collection.

Parameters
[out]fieldDefsAn array of FieldDef objects containing a collection of field definitions.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AddField ( const std::string &  fieldDef)

Adds a field to the table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
If you are adding an OBJECTID field and one already exists, a -2147219707 (The Fields collection contained multiple OID fields) error will be returned. Only one OBJECTID field is allowed.
If you are adding an GLOBALID field and one already exists, a -2147219703 (The Fields collection contained multiple Global ID fields) error will be returned. Only one GLOBALID field is allowed.
If you attempt to add a NOT NULLABLE field to a table already contains rows, a -2147219879 (The field is not nullable) will be returned.
If the field already exists, a -2147219884 (The Field already exists) will be returned.
FieldTypes XML

Parameters
[in]fieldDefAn XML document defining the field's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AddField ( const FieldDef fieldDef)

Adds a field to the table.

Parameters
[in]fieldDefA FieldDef object defining the field's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AlterField ( const std::string &  fieldDef)

Modifies a field in the table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
Alter allows a domain to be assigned to a field. No other field properties can be changed.

Parameters
[in]fieldDefAn XML document defining the field's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::DeleteField ( const std::wstring &  fieldName)

Deletes a field from the table.

If the field does not exist, an -2147219885 (An expected Field was not found or could not be retrieved properly) error will be returned.

Parameters
[in]fieldNameThe name of the field to delete.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetIndexes ( std::vector< std::string > &  indexDefs) const

Returns an XML definition of the table's index collection.

Parameters
[out]indexDefsAn XML document containing a collection of index definitions.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetIndexes ( std::vector< IndexDef > &  indexDefs) const

Returns an array of IndexDef objects of the table's index collection.

Parameters
[out]indexDefsAn array of IndexDef objects containing a collection of index definitions.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AddIndex ( const std::string &  indexDef)

Adds an index to the table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
XML

Parameters
[in]indexDefAn XML document defining the index's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AddIndex ( const IndexDef indexDef)

Adds an index to the table.

Parameters
[in]indexDefAn IndexDef object defining the index's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::DeleteIndex ( const std::wstring &  indexName)

Deletes an index from the table.

If the index is not found, an -2147219629 (The index was not found) error will be returned.

Parameters
[in]indexNameThe name of the index to delete.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::CreateSubtype ( const std::string &  subtypeDef)

Creates a new subtype to the table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
XML

Parameters
[in]subtypeDefAn XML document defining the subtype's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::AlterSubtype ( const std::string &  subtypeDef)

Modifies an existing subtype of the table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).

Parameters
[in]subtypeDefAn XML document defining the subtype's properties.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::DeleteSubtype ( const std::wstring &  subtypeName)

Deletes a subtype from the table.

Parameters
[in]subtypeNameThe name of the subtype to delete.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::EnableSubtypes ( const std::wstring &  subtypeFieldName,
const std::string &  subtypeDef 
)

Enables subtypes on a table.

If the XML is not UTF-8 encoded, create will fail with an error code of -2147024809 (Invalid function arguments).
FieldTypes XML

Parameters
[in]subtypeFieldNameThe field to use as the subtype field.
[in]subtypeDefThe field to use as the subtype Def.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetDefaultSubtypeCode ( int &  defaultCode) const

Returns the default subtype code.

Parameters
[out]defaultCodeThe table's default subtype code.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::SetDefaultSubtypeCode ( int  defaultCode)

Sets the default subtype code.

Parameters
[out]defaultCodeThe code to assign as the default subtype code.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::DisableSubtypes ( )

Drops the table's subtypes.

Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::Search ( const std::wstring &  subfields,
const std::wstring &  whereClause,
const Envelope envelope,
bool  recycling,
EnumRows rows 
)

Performs a spatial query (envelope intersects) on the table.

Parameters
[in]subfields(Optional) The fields that should be fetched by the query's returned rows. Must include a comma delimited list of fields or a "*". Passing in blank will return a -2147220985 (An invalid SQL statement was used) error.
[in]whereClause(Optional) Attribute constraints to apply to the query.
[in]envelopeThe spatial extent of the query.
[in]recyclingIndicates whether row memory should be recycled.
[out]rowsThe results of the query.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::Search ( const std::wstring &  subfields,
const std::wstring &  whereClause,
bool  recycling,
EnumRows rows 
)

Performs an attribute query on the table.

Parameters
[in]subfields(Optional) The fields that should be fetched by the query's returned rows. Must include a comma delimited list of fields or a "*". A blank will return a -2147220985 (An invalid SQL statement was used) error.
[in]whereClause(Optional) Attribute constraints to apply to the query.
[in]recyclingIndicates whether row memory should be recycled.
[out]rowsThe results of the query.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::CreateRowObject ( Row row)

Creates a new row in memory for the table.

Parameters
[out]rowThe newly-created row.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::Insert ( Row row)

Inserts a newly-created and populated row into the table.

When bulk inserting rows use LoadOnlyMode and SetWriteLock\FreeWriteLock to improve performance.

Parameters
[in]rowThe row to insert.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::Update ( Row row)

Updates an existing row in the table.

Parameters
[in]rowThe row to update.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::Delete ( Row row)

Deletes a row from the table.

Parameters
[in]rowThe row to delete.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::IsEditable ( bool &  isEditable)

Indicates whether the table should be edited.

Parameters
[out]isEditableTrue if the table can safely be edited.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetRowCount ( int &  rowCount) const

Returns the number of rows in the table.

Parameters
[out]rowCountThe number of rows in the table.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::GetExtent ( Envelope extent) const

Returns the extent of the feature class.

If the table is not a feature class an error of 1 will be returned.

Parameters
[out]extentThe extent of the feature class.
Returns
Error code indicating whether the method finished successfully.
fgdbError FileGDBAPI::Table::SetWriteLock ( void  )

Sets a write lock on a table.

This should be used when performing bulk updates and inserts. Otherwise a lock will be created for each update or insert. Should be followed by a call to FreeWriteLock.

fgdbError FileGDBAPI::Table::FreeWriteLock ( void  )

Frees a write lock on a table.

This should be used when performing bulk updates and inserts. Otherwise a lock will be created for each update or insert. Should be preceded by a call to SetWriteLock.

fgdbError FileGDBAPI::Table::LoadOnlyMode ( bool  loadOnlyMode)

Begin or End load only mode.

Parameters
[in]loadOnlyModetrue to begin LoadOnlyMode, false to end.