CTTable Class

Description

Objects of the CTTable class are used to manage tables. One table may belong to several databases, and a database may have multiple tables. The table may have any number of fields. It uses CTBase as the base class, and implements the constructor/destructor allocating/freeing memory to the table operations.

See Also

CTBase, CTDatabase, CTRecord

Preconditions

Before performing operations with a CTTable object, it is necessary to instantiate session and database objects.

CTTable Methods

Constructor / Destructor

  • CTTable(): Creates a CTTable object
  • Dispose(): Destroys a CTTable object and resets all the dependent objects

Table Handling

  • Alter(): Performs alter table functions
  • Close(): Closes a table
  • Create(): Creates a new table
  • CreateTable(): Creates a new table
  • GetCreateMode(): Retrieves the table create mode
  • GetDataDefaultExtentSize(): Retrieves the c-tree data file default extent size
  • GetDataExtension(): Retrieves the data file name extension
  • GetDatno(): Retrieves the table datno
  • GetGroupid(): Retrieves the table group id
  • GetIndexDefaultExtentSize(): Retrieves the c-tree index file default extent size
  • GetIndexExtension(): Retrieves the index file name extension
  • GetIndexFilename(): Retrieves the index name
  • GetName(): Retrieves the table name, without the name extension
  • GetOpenMode(): Retrieves the table open mode
  • GetPath(): Retrieves the table path.
  • GetPermission(): Retrieves the table permission mask
  • HasDelField(): Indicate if a table has the $DELFLD$ internal field
  • HasLocks(): Indicate if there are any locks on the table in the current session
  • HasNullFieldSupport(): Indicates if a table has null field support
  • IsActive(): Indicates if a table is open or closed
  • Open(): Opens an existing table
  • Remove(): Delete a table
  • ResetAll(): Resets all active record buffers associated with the table
  • SetDataDefaultExtentSize(): Sets the c-tree data file default extent size
  • SetDataExtension(): Sets the table data file extension
  • SetGroupid(): Sets the table groupid
  • SetIndexDefaultExtentSize(): Sets the c-tree index file default extent size
  • SetIndexExtension(): Sets the table index file extension
  • SetIndexFilename(): Sets the index filename
  • SetPassword(): Sets the table password
  • SetPath(): Sets the table path
  • SetPermission(): Sets the table permission mask
  • UnlockTable(): Unlocks all record locks from the table
  • UpdateCreateMode(): Updates the table create mode

Field Handling

  • AddField(): Adds a new field to table
  • DelField(): Deletes one field from the table
  • GetField(): Retrieves a field by its number or name
  • GetFieldCount(): Retrieves the number of fields in table
  • GetFieldNumber(): Retrieves the field number from a field name
  • GetPadChar(): Retrieves the table pad and field delimiter characters
  • InsertField(): Inserts a new field to table, in the specified position
  • MoveField(): Moves the field from one position to a new position in the table
  • SetPadChar(): Set the table pad and field delimiter characters
  • UpdatePadChar(): Update the table pad and delimiter character resource

Index Handling

  • AddIndex(): Adds a new index to the table
  • DelIndex(): Deletes an index from a table
  • GetCndxIndex(): Retrieves the conditional index expression string
  • GetIndex(): Retrieves an index object
  • GetIndexByUID(): Retrieves the index given its UID
  • GetIndexCount(): Retrieves the number of indexes of the table
  • GetIdxno(): Retrieves the index file number given the index number
  • HasRecbyt(): Indicates if a table was created with support to a recbyt index
  • HasRowid(): Indicates if a table was created with support to a rowid index
  • UpdateCndxIndex(): Add, modify or delete conditional index

Segment Handling

  • AddSegment(): Retrieves an index segment object
  • DelSegment(): Deletes an existing segment
  • GetSegment(): Adds a new segment to an index
  • InsertSegment(): Inserts a new segment

System Filters

  • SystemFilterOn(): Establish a permanent system wide record filter
  • SystemFilterOff(): Delete a permanent system wide record filter

CTTable.AddField

Syntax

CTField AddField( String Name, FIELD_TYPE Type, int Length)

Parameters

  • Name [in] - The field name to add to the table
  • Type [in] - The field type. Valid field type values are shown in the "Field Types".
  • Length [in] - The field length, the maximum length of [VAR]CHAR or [VAR]BINARY field in bytes (64K max). Set to 0 for "unlimited" (2GB) LVARCHAR.

Description

Adds a new field to table.

Return

AddField() returns a field object on success or NULL on failure.

See Also

AddIndex(), DelField(), GetField(), InsertField()

CTTable.AddField (by field object)

Add a new segment to an FTI index.

See CTTable.AddField

CTTable.AddField (by name)

Add a new segment to an FTI index using the field name.

See CTTable.AddField

CTTable.AddField (by number)

Add a new segment to an FTI index using the field number.

See CTTable.AddField

CTTable.AddFullTextIndex

Add a new Full-Text Index to the table.

See CTTable.AddFullTextIndex

CTTable.AddIndex

Syntax

CTIndex AddIndex( String name, KEY_TYPE KeyType,

bool AllowDuplicates, bool NullFlag)

Parameters

  • name [in] The index name to add to the table.
  • KeyType [in] The index type. Allowed types are:
    • KEY_TYPE. FIXED_INDEX
    • KEY_TYPE.LEADING_INDEX
    • KEY_TYPE.PADDING_INDEX
    • KEY_TYPE.LEADPAD_INDEX
    • KEY_TYPE.ERROR_INDEX
  • AllowDuplicates [in] The flag indicating if the index accepts duplicates or not.
  • NullFlag [in] The flag indicating if Null fields are allowed or not.

Description

Adds a new index to the table.

Return

None.

See Also

AddField(), DelIndex(), HasNullFieldSupport()

CTTable.Alter

Syntax

void Alter(ALTER_TABLE Action)

Parameters

  • Action [in] The alter table action. One or more of the following actions can be selected:
    • ALTER_TABLE.NORMAL: Check for changes before altering
    • ALTER_TABLE.INDEX: Force rebuild of all indexes
    • ALTER_TABLE.FULL: Force full table rebuild.
    • ALTER_TABLE_TRUNCATE: Quickly remove all records.
    • ALTER_TABLE.PURGEDUP: OR in with any of the other modes to deal with cases where an alter table is performed on data files with duplicated index information.
    • ALTER_TABLE.KEEPTRAN: Allow tables with different TRANDEP modes (e.g. transaction capable, however, transaction control disabled for performance) to undergo ALTER TABLE. (This is generally an internal FairCom operation for certain table types.)

Description

Performs alter table functions. This method may be used to update a table after its creation. The table must be open in OPEN_MODE.EXCLUSIVE_OPEN() mode before it is updated.

Return

None.

See Also

Open()

CTTable.Attach

Attaches a c-tree Plus ISAM datno object to a c-tree.NET table object.

Declaration

void CTTable.Attach(NINT datno);

Description

CTTable.Attach() attaches a c-tree ISAM datno object to a FairCom DB API .NET table object. This function is useful if you have opened a data and index file using one of c-tree’s ISAM open functions and need to attach it to a table handle to use advanced FairCom DB API .NET features such as alter table or record and field handling. datno is data file number opened with one of the c-tree ISAM open functions.

Return

void

Example


CTSession hSession(CTSESSION_CTREE);

CTTable hTable(hSession);

CTRecord hRecord(hTable);

NINT datno, count = 0;

// logon to c-tree

hSession.Logon(SERVER, USER, PASSWD);
 

// open the file using c-tree ISAM

datno = (NINT)OPNRFILX((COUNT) -1, "test309.dat", (COUNT)0, NULL);
 

// attach to table

hTable.Attach(datno);
 

// read the records

if (hRecord.First())

do

{

count++;

}

while (hRecord.Next());
 

// cleanup

hTable.Detach();

hSession.Logout();
 

See Also

CTTable.AttachXtd(), CTTable.Detach()

CTTable.Clone

Syntax

void Clone(CTTable Target, String TargetName)

Parameters

  • Target - The new table handle
  • TargetName [in] - The new table name (without file extension)

Description

Creates a new table with the attributes from an existing source table. This does NOT create a duplicate table -- records are not copied.

Note: This function is only for a CTSESSION_CTREE session or for cloning tables from/into different databases.

Return

None. Throws a CTException on error. Typical CreateTable() exceptions are possible.

See also

CTTable::CreateTable()

CTTable.Close

Syntax

void Close( )

Parameters

This method has no parameters.

Description

Closes a table.

Return

None.

See Also

Open()

CTTable.Create

Syntax

void Create(String Name, CREATE_MODE CreateMode)

Parameters

Description

Creates a new table. Before the table creation, it must be defined with AddField(), and optionally with AddIndex() and AddSegment().

Return

None.

See Also

AddField(), GetCreateMode(), Open()

CTTable.CreateTable

Syntax

void CreateTable(String Name, CREATE_MODE CreateMode)

Parameters

Description

The two methods, Create() and CreateTable(), are equivalent. CreateTable() must be used in Delphi environment.

Return

None.

See Also

AddField(), GetCreateMode(), Open()

CTTable.CTTable

Syntax

CTTable( CTDatabase Handle)

CTTable( CTSession Handle)

Parameters

Handle [In]Is the database or session object. When the CTTable(CTDatabase Handle) prototype is used, Handle is a database object. When the CTTable(CTSession Handle) prototype is used, Handle is a session object. The CTTable object being created is a child of the CTDatabase or CTSession object.

Description

This is the constructor for the CTTable class.

See Also

Dispose()

CTTable.DelField

Syntax

void DelField( int FieldNumber)

void DelField( String FieldName)

Parameters

  • FieldNumber [in] Delete this field number, if the prototype DelField(int FieldNumber) is used.
  • FieldName [in] Delete this field name, if the prototype DelField(String FieldName) is used.

Description

Deletes a field from the table.

Return

None.

See Also

AddField(), CTDatabase.DeleteTable(), InsertField()

CTTable.DelFullTextIndex (by index name)

Delete a Full-Text Index from a table using the index name.

See CTTable.DelFullTextIndex

CTTable.DelFullTextIndex (by index number)

Delete a Full-Text index from a table using the index number.

See CTTable.DelFullTextIndex

CTTable.DelIndex

Syntax

void DelIndex(int IndexNumber)

void DelIndex(String IndexName)

Parameters

  • IndexNumber [in] Index number to be deleted, if the prototype DelIndex(int IndexNumber) is used.
  • IndexName [in] Index name to be deleted, if the prototype DelIndex(String IndexName) is used.

Description

Deletes an index from a table, either by name or number.

Return

None.

See Also

AddIndex(), DelField()

CTTable.DelSegment

Syntax

void DelSegment(int IndexNumber, int SegNumber)

void DelSegment(String IndexName, int SegNumber)

Parameters

  • IndexNumber [in] The index number whose segment is to be deleted.
  • SegNumber [in] The segment number to be deleted.
  • IndexName [in] The index name whose segment is to be deleted.

Description

Deletes an existing segment.

Return

None.

See Also

AddSegment(), InsertSegment()

CTTable.Detach

Detaches a FairCom DB API .NET table object from a c-tree data and index files.

Declaration

void CTTable.Detach();

Description

CTTable.Detach() detaches a FairCom DB API .NET table object from a c-tree data and index files. The table is not closed but the FairCom DB API .NET table handle resources are released and the handle re-initialized.

Return

void

Example


CTSession hSession(CTSESSION_CTREE);

CTTable hTable(hSession);

CTRecord hRecord(hTable);

NINT datno, count = 0;

// logon to c-tree

hSession.Logon(SERVER, USER, PASSWD);
 

// open the file using c-tree ISAM

datno = (NINT)OPNRFILX((COUNT) -1, "test309.dat", (COUNT)0, NULL);
 

// attach to table

hTable.Attach(datno);
 

// read the records

if (hRecord.First())

do

{

count++;

}

while (hRecord.Next());
 

// cleanup

hTable.Detach();

hSession.Logout();|
 

See Also

CTTable.Attach(), CTTable.AttachXtd()

CTTable.Dispose

Syntax

void Dispose()

Parameters

This destructor has no parameters.

Description

This is the destructor for the CTTable class. It frees the allocated memory to the Table. No table operations are allowed after the CTTable() destructor is called.

See Also

CTTable()

CTTable.GetCndxIndex

Syntax

void GetCndxIndex(int indexnbr, StringBuilder cndexpr)

void GetCndxIndex(String indexname, StringBuilder cndexpr)

Parameters

  • indexnbr [in] index number
  • indexname [in] index name
  • cndexpr [out] conditional index expression

Description

Retrieves the conditional index expression string, given the index number.

Return

None.

See Also

GetCndxIndexByName(), GetCndxIndexLength(), GetCndxIndexLengthByName()

CTTable.GetCreateMode

Syntax

CREATE_MODE GetCreateMode( )

Parameters

This method has no parameters.

Description

Retrieves the table create mode. The valid values for the table create mode are shown in "Table Create Modes (CREATE_MODE enum)".

Return

GetCreateMode() returns the table create mode.

See Also

Create(), GetOpenMode()

CTTable.GetDataDefaultExtentSize

Syntax

int GetDataDefaultExtentSize( )

Parameters

This method has no parameters.

Description

Retrieves the c-tree data file default extent size. The default value, 0 bytes, may be changed by calling SetDataDefaultExtentSize().

Return

GetDataDefaultExtentSize() returns the default data file extent size.

See Also

GetIndexDefaultExtentSize(), SetDataDefaultExtentSize()

CTTable.GetDataExtension

Syntax

String GetDataExtension( )

Parameters

This method has no parameters.

Description

Gets the data file name extension. If not changed by SetDataExtension(), the data extension is .dat.

Return

GetDataExtension() returns the data file name extension

See Also

GetIndexExtension(), SetDataExtension()

CTTable.GetDatno

Syntax

int GetDatno()

Parameters

This method has no parameters.

Description

Retrieves the table file number.

Return

GetDatno() returns the table datno.

CTTable.GetField

Syntax

CTField GetField(int FieldNumber)

CTField GetField(String FieldName)

Parameters

  • FieldNumber [in] The field number to be retrieved from the table. The first field in the table is field number zero.
  • FieldName [in] The field name to be retrieved from the table.

Description

Retrieves a field by its number or name. The first field in the table is the field number zero.

Return

GetField() returns the field object.

See Also

GetFieldCount(), GetFieldNumber()

CTTable.GetFieldCount

Syntax

int GetFieldCount( )

Parameters

This method has no parameters.

Description

Retrieves the number of fields in the table

Return

GetFieldCount() returns the number of fields.

See Also

AddField(), DelField(), GetFieldNumber(), GetIndexCount(), InsertField()

CTTable.GetFieldNumber

Syntax

int GetFieldNumber(String FieldName)

Parameters

  • FieldName [in] The field name whose field number is to be retrieved from the table.

Description

Retrieves the field number from a table, given its field name.

Return

GetFieldNumber() returns the field number.

See Also

GetField(), GetFieldCount()

CTTable.GetFirstPartition

Syntax

LONG CTTable.GetFirstPartition()

Parameters

None

Description

Retrieves the first raw partition number, if the table is a partitioned file.

Return

CTException is thrown if the table is not a partitioned file.

See Also

GetLastPartition()

CTTable.GetFullTextIndex (by index name)

Retrieve the Full-Text Index using its name.

See CTTable.GetFullTextIndex

CTTable.GetFullTextIndex (by index number)

Retrieve a Full-Text Index object using the index number.

See CTTable.GetFullTextIndex

CTTable.GetFullTextIndexCount

Retrieve the number of Full-Text Indexes of this table.

See CTTable.GetFullTextIndexCount

CTTable.GetGroupid

Syntax

String GetGroupid( )

Parameters

This method has no parameters.

Description

Retrieves the table group id

Return

GetGroupid() returns the table group id.

See Also

SetGroupid()

CTTable.GetIdentityField

Syntax

String GetIdentityField()

Parameters

None

Description

Returns the name of the Identity field.

Return

Field name of the identity field.

See Also

GetIdentityFieldDetails(), GetLastIdentity(), SetIdentityField()

CTTable.GetIdentityFieldDetails

Syntax

String GetIdentityFieldDetails(out long Seed, out long Increment)

Parameters

  • Seed [out] seed value
  • Increment [out] increment value

Description

Returns the name, seed, and increment values of the Identity field.

Return

Field name, seed, and increment of the identity field.

See Also

GetIdentityField(), GetLastIdentity(), SetIdentityField()

CTTable.GetIdxNo

Syntax

int GetIdxNo(int IndexNumber )

int GetIdxNo(String Name )

Parameters

  • IndexNumber [in] The Index number to be retrieved.
  • Name [in] The index name to be retrieved.

Description

Retrieves the index file number

Return

GetIdxNo() returns the index datno.

See Also

SetGroupid()

CTTable.GetIndex

Syntax

CTIndex GetIndex(int IndexNumber)

CTIndex GetIndex(String name)

Parameters

  • IndexNumber [in] The Index number to be retrieved.
  • name [in] The index name to be retrieved.

Description

Retrieves an index object, given its number or name.

Return

GetIndex() returns the Index object.

See Also

DelIndex, AddIndex

CTTable.GetIndexByUID

Syntax

CTIndex GetIndexByUID(ulong uid)

Parameters

  • uid [in] the index unique identifier.

Description

Retrieves the index object given its unique identifier.

Return

GetIndexByUID() returns the index object.

See Also

GetIndex()

CTTable.GetIndexCount

Syntax

int GetIndexCount( )

Parameters

This method has no parameters.

Description

Retrieves the number of table indexes

Return

GetIndexCount() returns the number of indexes.

See Also

GetFieldCount()

CTTable.GetIndexDefaultExtentSize

Syntax

int GetIndexDefaultExtentSize( )

Parameters

This method has no parameters.

Description

Retrieves the c-tree index file default extent size

Return

GetIndexDefaultExtentSize() returns the default index file extent size. The default value, 0 bytes, may be changed by SetIndexDefaultExtentSize().

See Also

GetDataDefaultExtentSize(), SetIndexDefaultExtentSize()

CTTable.GetIndexExtension

Syntax

String GetIndexExtension( )

Parameters

This method has no parameters.

Description

Gets the index file name extension (usually .idx).

Return

GetIndexExtension() returns the index file name extension. If not changed by SetIndexExtension(), the index extension is .idx.

See Also

GetDataExtension(), SetIndexExtension()

CTTable.GetIndexFilename

Syntax

String GetIndexFilename(int IndexNumber)

String GetIndexFilename(String name)

Parameters

  • IndexNumber [in] The Index number to be retrieved.
  • name [in] The index name to be retrieved.

Description

Return the name of the index file. If Index name is NULL the returned string will be cleared.

Return

GetIndexFilename() returns the name of the index file.

See Also

GetIndex()

CTTable.GetLastIdentity

Syntax

long GetLastIdentity()

Parameters

None.

Description

Returns the last Identity value.

Return

Last Identity value.

See Also

GetIdentityField(), GetIdentityFieldDetails(), SetIdentityField()

CTTable.GetLastPartition

Syntax

LONG CTTable.GetLastPartition()

Parameters

None

Description

Retrieves the last raw partition number, if the table is a partitioned file.

Return

CTException is thrown if the table is not a partitioned file.

See Also

GetFirstPartition()

CTTable.GetName

Syntax

String GetName( )

Parameters

This method has no parameters.

Description

Gets the table name, without the name extension.

Return

GetName() returns the table name.

Example

aTable = aDatabase.FirstTable();

Console.Write("\nFirst table: {0}", aTable.GetName());

See Also

GetOpenMode(), GetPath(), GetPermission()

CTTable.GetOpenMode

Syntax

OPEN_MODE GetOpenMode( )

Parameters

This method has no parameters.

Description

Retrieves the table open mode. The valid values for the table open mode are shown in "Table Open Modes (OPEN_MODE enum)".

Return

GetOpenMode() returns the table open mode.

See Also

GetCreateMode(), Open()

CTTable.GetPadChar

Syntax

void GetPadChar(out sbyte Padchar, out sbyte Dmlchar)

Parameters

  • Padchar [out] receive the pad character
  • Dmlchar [out] receive the field delimiter character

Description

Retrieve the table pad and field delimiter characters. These characters are used to pad fixed string fields (FSTRING) to allow proper target key formation.

Return

None.

See Also

SetPadChar(), UpdatePadChar()

CTTable.GetPassword

Syntax

String GetPassword( )

Parameters

This method has no parameters.

Description

Retrieves the table password

Return

GetPassword() returns the table password

See Also

GetName(), GetPath(), SetPassword()

CTTable.GetPath

Syntax

String GetPath( )

Parameters

This method has no parameters.

Description

Gets the table path.

Return

GetPath() returns the table path.

See Also

GetName()

CTTable.GetPermission

Syntax

int GetPermission( )

Parameters

This method has no parameters.

Description

Retrieves the table permission mask. The valid values for the table permission mask are shown in "Table Permissions (TABLE_PERMS enum)".

Return

GetPermission() returns the table permission mask.

See Also

SetPermission()

CTTable.GetSegment

Syntax

CTSegment GetSegment( CTIndex Index, int SegNumber)

Parameters

  • Index [in] The index object whose segment is to be retrieved
  • SegNumber [in] The segment number to be retrieved

Description

Retrieves an index segment object

Return

GetSegment() returns the segment object

See Also

AddSegment(), DelSegment(), InsertSegment()

CTTable.HasDelField

Syntax

bool HasDelField( )

Parameters

This method has no parameters.

Description

Indicate if a table has the $DELFLD$ internal field.

Return

Return true if the table has $DELFLD$ field and false if the table has no $DELFLD$ field or if the handle is invalid (not allocated, the table is not opened, is not a table handle, etc).

CTTable.HasLocks

Syntax

bool HasLocks( )

Parameters

This method has no parameters.

Description

Indicate if there are any locks on the table in the current session.

Return

Return true if any locks are present.

CTTable.HasNullFieldSupport

Syntax

bool HasNullFieldSupport( )

Parameters

This method has no parameters.

Description

Indicates if a table has null field support.

Return

HasNullFieldSupport() returns true if the table has null field support, false otherwise.

CTTable.HasRecbyt

Syntax

bool HasRecbyt( )

Parameters

This method has no parameters.

Description

Indicates if a table has support to a RECBYT index or not. By default, when a table is created it has support to this index enabled.

Return

HasRecbyt() returns true if the table has support to the RECBYT index, false otherwise.

See Also

Create()

CTTable.HasRowid

Syntax

bool HasRowid( )

Parameters

This method has no parameters.

Description

Indicates if a table has support to a ROWID index or not. By default, when a table is created it has support to this index enabled. A ROWID index is an automatic sequence number.

Return

HasRecbyt() returns true if the table has support to the ROWID index, false otherwise.

See Also

Create(), Record.FindRowid(), Record.GetRowid()

CTTable.InsertField

Syntax

CTField InsertField( int BeforeField, String Name, FIELD_TYPE Type,

int Length)

CTField InsertField( String BeforeField, String Name, FIELD_TYPE Type,

int Length)

Parameters

  • BeforeField [in] Insert the new field before this field number, if the prototype InsertField(int BeforeField, String Name, FIELD_TYPE Type, int Length) is used. Insert the new field before this field name, if the prototype InsertField(String BeforeField, String Name, FIELD_TYPE Type, int Length) is used.
  • Name [in] The field name to insert in the table
  • Type [in] the field type. Valid field type values are shown in "Field Types".
  • Length [in] the field length

Description

Inserts a new field into the table, in the specified position.

Return

InsertField() returns a field object on success or NULL on failure.

See Also

AddField(), DelField(), GetFieldNumber()

CTTable.InsertSegment

Syntax

CTSegment InsertSegment( CTIndex Index, int BeforeSegment, CTField Field, SEG_MODE SegMode)

CTSegment InsertSegment( CTIndex Index, int BeforeSegment, String FieldName, SEG_MODE SegMode)

CTSegment InsertSegment( CTIndex Index, int BeforeSegment, int FieldNumber, SEG_MODE SegMode)

CTSegment InsertSegment( CTIndex Index, int BeforeSegment, int offset, int length, SEG_MODE SegMode)

CTSegment InsertSegment(int IndexNbr, int BeforeSegment, int FieldNumber, SEG_MODE SegMode)

CTSegment InsertSegment(int IndexNbr, int BeforeSegment, String FieldName, SEG_MODE SegMode)

CTSegment InsertSegment( String IndexName, int BeforeSegment, String FieldName, SEG_MODE SegMode)

CTSegment InsertSegment( String IndexName, int BeforeSegment, int FieldNumber, SEG_MODE SegMode)

CTSegment InsertSegment( String IndexName, int BeforeSegment, CTField Field, SEG_MODE SegMode)

CTSegment InsertSegment(int IndexNbr, int BeforeSegment, CTField Field, SEG_MODE SegMode)

Parameters

  • Index [in] The index object.
  • BeforeSegment [in] Insert the new segment before this segment.
  • Field [in] The field object that composes part of the index segment
  • SegMode [in] The segment mode. The valid values to the segment mode are shown in "Segment Modes".
  • FieldName [in] Field name to compose the index segment
  • FieldNumber [in] Field number to compose the index segment
  • offset [in] Absolute byte offset of the segment
  • Length [in] Segment length in bytes
  • IndexNbr [in] Index number
  • IndexName [in] Index name
  • Field [in] Field segment to be inserted

Description

Inserts a new segment in an index.

Return

InsertSegment() returns a segment object.

See Also

AddSegment(), DelSegment()

CTTable.IsActive

Syntax

bool IsActive( )

Parameters

This method has no parameters.

Description

Indicates if a table is open or closed.

Return

IsActive() returns true if the table is open and false otherwise.

Example

if (!aTable.IsActive())

aTable.Open(tb_name, OPEN_MODE.NORMAL_OPEN);

See Also

Open()

CTTable.MoveField

Syntax

void MoveField( int FieldNumber, int newNumber)

void MoveField( String FieldName, int newNumber)

Parameters

  • FieldNumber [in] The field number to be moved, if the prototype MoveField(int FieldNumber, int newNumber) is used.
  • newNumber [in] The new field number in the table.
  • FieldName [in] The field name to be moved, if the prototype MoveField(String FieldName, int newNumber) is used.

Description

Moves the field from one position to another position in the same table.

Return

None.

See Also

AddField(), DelField(), InsertField()

CTTable.MoveSegment

Moves a key segment.

Declaration

void CTTable.MoveSegment(CTIndex hIndex, NINT segNumber, NINT newIndex);

void CTTable.MoveSegment(NINT indexNumber, NINT segNumber, NINT newIndex);

void CTTAble.MoveSegment(const CTString& indexName, NINT segNumber, NINT newIndex);

Description

CTTable.MoveSegment() moves a key segment to a location indicated by newIndex. hIndex is a index object, indexNumber is a relative number for a index object in a table definition and indexName is the unique name for the index. newIndex indicate the relative position were the key segment should be moved to.

Return

void

Example


// move the last segment to first

CTIndex hIndex = hTable.GetIndex(0);

NINT count = hIndex.GetSegmentCount();
 

if (count > 0)

hTable.MoveSegment(hIndex, (count - 1), 0);
 

See Also

CTIndex.MoveSegment(), CTSegment.MoveSegment()

CTTable.Open

Syntax

void Open( String Name, OPEN_MODE OpenMode)

Parameters

  • Name [in] The table name
  • OpenMode [in] The open mode for the table. The valid values for the table open mode are shown in "Table Open Modes (OPEN_MODE enum)".

Description

Opens an existing table.

Return

None.

See Also

Close(), Create(), GetOpenMode()

CTTable.PartAdminByKey

Performs an administrative partition operation on the partition specified by key value.

Declaration

COUNT PartAdminByKey( IntPtr key, CTPART_MODE_E partmode );

Description

PartAdminByKey() manages the partitions for a table.

  • keyval [in] - pointer to a partition key value that has been transformed
  • partmode [in] - partition operation mode. partmode is one of of the CTPART_MODE_E enums:

 

PURGE

delete a partition

 

ADD

add a partition

 

ARCHIVE

archive a partition

 

BASE

modify the lower limit partition number value

 

ACTIVATE

activate an archived partition

 

STATUS

return the partition status in partstatus

Return Values

CTDBRET_NOERROR is returned if no error.

If CTPART_MODE_E.STATUS is passed as a partition mode, then one of the following partstatus values is returned:

pmSTATUSnone

0

Partition member does not exist.

pmSTATUSexst

1

Partition member is active.

pmSTATUSopnd

2

Partition member is active and currently open.

pmSTATUSarhv

3

Partition member is archived.

pmSTATUSpurg

4

Partition member was purged.

pmSTATUSparc

19

Partition member is pending archive.

pmSTATUSppnd

20

Partition member is pending purge.

See Also

CTTable.PartAdminByName(), CTTable.PartAdminByNumber()

CTTable.PartAdminByName

Performs an administrative partition operation on the partition specified by partition name.

Declaration

COUNT PartAdminByName( String partname, CTPART_MODE_E partmode );

Description

PartAdminByName() manages the partitions for a table.

  • partname [in] - partition name.
  • partmode [in] - partition operation mode. partmode is one of of the CTPART_MODE_E enums:

 

PURGE

delete a partition

 

ADD

add a partition

 

ARCHIVE

archive a partition

 

BASE

modify the lower limit partition number value

 

ACTIVATE

activate an archived partition

 

STATUS

return the partition status in partstatus

Return Values

CTDBRET_NOERROR is returned if no error.

If CTPART_MODE_E.STATUS is passed as a partition mode, then one of the following partstatus values is returned:

pmSTATUSnone

0

Partition member does not exist.

pmSTATUSexst

1

Partition member is active.

pmSTATUSopnd

2

Partition member is active and currently open.

pmSTATUSarhv

3

Partition member is archived.

pmSTATUSpurg

4

Partition member was purged.

pmSTATUSparc

19

Partition member is pending archive.

pmSTATUSppnd

20

Partition member is pending purge.

See Also

CTTable.PartAdminByKey(), CTTable.PartAdminByNumber()

CTTable.PartAdminByNumber

Performs an administrative partition operation on the partition specified by partition number.

Declaration

COUNT PartAdminByNumber( LONG partno, CTPART_MODE_E partmode );

Description

PartAdminByKey() manages the partitions for a table.

  • partno [in] - partition number
  • partmode [in] - partition operation mode. partmode is one of of the CTPART_MODE_E enums:

 

PURGE

delete a partition

 

ADD

add a partition

 

ARCHIVE

archive a partition

 

BASE

modify the lower limit partition number value

 

ACTIVATE

activate an archived partition

 

STATUS

return the partition status in partstatus

Return Values

CTDBRET_NOERROR is returned if no error.

If CTPART_MODE_E.STATUS is passed as a partition mode, then one of the following partstatus values is returned:

pmSTATUSnone

0

Partition member does not exist.

pmSTATUSexst

1

Partition member is active.

pmSTATUSopnd

2

Partition member is active and currently open.

pmSTATUSarhv

3

Partition member is archived.

pmSTATUSpurg

4

Partition member was purged.

pmSTATUSparc

19

Partition member is pending archive.

pmSTATUSppnd

20

Partition member is pending purge.

See Also

CTTable.PartAdminByKey(), CTTable.PartAdminByName()

CTTable.Rebuild

Declaration

CTTable.Rebuild(CTREBUILD_MODE mode);

Description

  • See AlsoHandle [IN] Table handle
  • mode [IN] The following modes are available:

CTREBUILD Mode

Description

CTREBUILD_NONE

The normal rebuild mode.

CTREBUILD_PURGEDUP

Purge duplicate records during rebuild.

CTREBUILD_UPDATEIFIL

Update the IFIL structure in the table.

CTREBUILD_DATAONLY

Rebuild only the datafile.

CTREBUILD_COMPACT

Compact and rebuild.

Note: Exercise care when using CTREBUILD_DATAONLY and CTCREBUILD_UPDATEIFIL modes together as the index files will be removed from the table IFIL definition even if the index files still exist in the file system. This can cause later problems if Alter() is called to recreate the removed indexes.

Rebuild() calls the FairCom DB CTRBLIFILX() function to rebuild a c-tree table. When used in conjunction with the open modes CTOPEN_CORRUPT and CTOPEN_DATAONLY, the Rebuild() function can be used as a direct replacement for the c-tree Plus ctrbldif rebuild utility.

The following steps are performed by FairCom DB API during a table rebuild process:

  1. If a transaction is active, and the table being rebuilt was created with CTCREATE_TRNLOG or CTCREATE_PREIMG, the transaction is committed before the table is rebuilt, and the transaction is restarted after the table rebuild process is completed.
  2. The update corrupt flag, updflg, of the header of the data file is cleared.
  3. The internal delete stack chain of fixed-length data files or the internal delete management index of variable length data files are rebuilt.
  4. The existing index files are removed and new index files are rebuilt over the existing files, optimized for both size and speed.

You must open the table before Rebuild() is executed. It is recommended that the table be opened with CTOPEN_EXCLUSIVE mode. If the table is corrupt, you will need to open the table with the CTOPEN_CORRUPT mode and then call Rebuild() to rebuild the data and index files. If there are missing or corrupt index files, open the table with CTOPEN_DATAONLY mode and Rebuild() will reconstruct the missing index files.

There may be situations when you need to invoke this function to rebuild only the data file. After the data file rebuild is successful, you may need to call Rebuild() again to rebuild the index files.

Return Values

Check CTExecption for DUPJ_ERR (650, Duplicate keys purged and logged) that may be returned.

See Also

Alter()

CTTable.Remove

SYNTAX

CTTable.Remove( )

PARAMETERS

This method has no parameters.

DESCRIPTION

Delete a table. If the table was open under a database, the table is first dropped from the database and then deleted.

RETURN

None.

CTTable.ResetAll

Syntax

void ResetAll( )

Parameters

This method has no parameters.

Description

Resets all active record buffers associated with the table

Return

None.

CTTable.SetDataDefaultExtentSize

Syntax

void SetDataDefaultExtentSize(int size)

Parameters

  • size [in] The default data extent size. The data extent default value is 0 initially.

Description

Sets the c-tree data file default extent size. Each time the data file needs to be extended, it will use this value to extent the file. If not changed by SetDataDefaultExtentSize(), this value is 0 bytes.

Return

None.

See Also

GetDataDefaultExtentSize(), SetIndexDefaultExtentSize()

CTTable.SetDataExtension

Syntax

void SetDataExtension(String Ext)

Parameters

  • Ext [in] The table extension, usually .dat (default value).

Description

Sets the table data file extension. If not changed by SetDataExtension(), the data extension is .dat.

Return

None.

See Also

GetDataExtension(), SetIndexExtension()

CTTable.SetFullTextIndexOption (by index object)

Set Full-Text Index options using the Full-Text Index object.

See CTTable.SetFullTextIndexOption

CTTable.SetFullTextIndexOption (by name)

Set Full-Text Index options using the Full-Text Index name.

See CTTable.SetFullTextIndexOption

CTTable.SetFullTextIndexOption (by number)

Set Full-Text Index options using the Full-Text Index number.

See CTTable.SetFullTextIndexOption

CTTable.SetGroupid

Syntax

void SetGroupid(String Groupid)

Parameters

  • Groupid [in] The new table Group id.

Description

Sets the table group id.

Return

None.

See Also

GetGroupid()

CTTable.SetIdentityField

Syntax

void SetIdentityField(String FieldName, long Seed, long Increment)

Parameters

  • FieldName [in] The identity field
  • Seed [in] The starting value
  • Increment [in] The increment

Description

Sets a field to be an identity field starting with Seed value and incrementing by Increment.

Return

None.

See Also

GetIdentityField(), GetIdentityFieldDetails(), GetLastIdentity()

CTTable.SetIndexDefaultExtentSize

Syntax

void SetIndexDefaultExtentSize(int size)

Parameters

  • size [in] The default index extent size. The index extent default value is 0 initially.

Description

Sets the c-tree index file default extent size. Each time the index file needs to be extended, it will use this value to extent the file. If not changed by SetIndexDefaultExtentSize(), this value is 0 bytes.

Return

None.

See Also

GetIndexDefaultExtentSize(), SetDataDefaultExtentSize()

CTTable.SetIndexExtension

Syntax

void SetIndexExtension(String Ext)

Parameters

  • Ext [in] The table index file extension, usually .idx (default value).

Description

Sets the table index file extension. If not changed by SetIndexExtension(), the index extension is .idx.

Return

None.

See Also

GetIndexExtension(), SetDataExtension()

CTTable.SetIndexFilename

Syntax

void SetIndexFilename(int IndexNumber, String Path, String Filename)

void SetIndexFilename(String IndexName, String Path, String Filename)

Parameters

  • IndexNumber [in] Number of index to set the filename.
  • IndexName [in] Name of index to set the filename.
  • Path [in] Index path. If NULL use the table path.
  • Filename [in] Index file name. If NULL use the table name.

Description

Set the index filename.

Return

None.

CTTable.SetOwner

Declaration

void CTTable.SetOwner(const CTString& owner)

Description

Sets the table owner. You should set the table owner before the table is created to allow the proper c-tree security setting to take place.

Return Values

None.

See Also

CTTable.GetOwner()

CTTable.SetPadChar

Syntax

void SetPadChar(int Padchar, int Dmlchar)

Parameters

  • Padchar [in] pad character
  • Dmlchar [in] field delimiter character

Description

Set the table pad and field delimiter characters in the table object. These characters are used to pad fixed string fields (FSTRING) to allow proper target key formation.

Return

None.

See Also

GetPadChar(), UpdatePadChar()

CTTable.SetPassword

Syntax

void SetPassword(String Password)

Parameters

  • Password [in] The new table password.

Description

Sets the table password

Return

None.

See Also

GetPassword()

CTTable.SetPath

Syntax

void SetPath(String Path)

Parameters

  • Path [in] the new table path.

Description

Sets the table path.

Return

None.

See Also

GetPath()

CTTable.SetPermission

Syntax

void SetPermission(int Permmask)

Parameters

Description

Sets the table permission mask.

Return

None.

See Also

GetPermission()

CTTable.SystemFilterOff

Syntax

void SystemFilterOff(SYS_FILTER mode)

PARAMETERS

  • mode [in]: Filter mode

DESCRIPTION

Delete a permanent system wide (i.e., the filter applies to all users) read and/or write. This method requires low level c-tree programming. Please ask FairCom for further information.

RETURN

None.

SEE ALSO

SystemFilterOn()

CTTable.SystemFilterOn

SYNTAX

void SystemFilterOn(SYS_FILTER mode)

PARAMETERS

  • mode [in]: Filter mode

DESCRIPTION

Establish a permanent system wide (i.e., the filter applies to all users) read and/or write. This method requires low level c-tree programming. Please contact your local FairCom office for implementation details.

RETURN

None.

SEE ALSO

SystemFilterOff()

CTTable.UnlockTable

Syntax

void UnlockTable( )

Parameters

None.

Description

Unlocks all record locks from the table, if they were obtained with a call to CTRecord.LockRecord(). To free a specific record lock obtained with CTRecord.LockRecord(), use CTRecord.UnlockRecord().

Return

None.

See Also

CTRecord.LockRecord(), CTRecord.UnlockRecord()

CTTable.UpdateCndxIndex

Syntax

void UpdateCndxIndex(int IndexNumber, String CndxExpr)

void UpdateCndxIndex(int name, String CndxExpr)

Parameters

  • IndexNumber [in] The Index number to update.
  • name [in] The index name to update.
  • CndxExpr [in] Conditional index expression.

Description

Add, modify or delete conditional index.

Return

None.

CTTable.UpdateCreateMode

Syntax

void UpdateCreateMode(CREATE_MODE mode)

Parameters

  • mode [in] Represents the new table create mode. It must be perfectly formed, as it will replace the current table create mode. Use the method GetCreateMode() to retrieve the current create mode and apply the changes on a fully qualified create mode. Update only the following create table modes:
    • CREATE_ MODE.PREIMG_CREATE
    • CREATE_ MODE.TRNLOG_CREATE
    • CREATE_ MODE.WRITETHRU_CREATE
    • CREATE_ MODE.CHECKLOCK_CREATE
    • CREATE_ MODE.CHECKREAD_CREATE
    • CREATE_MODE.HUGEFILE_CREATE

Description

Update the table create mode. This method changed critical file mode attributes such as the level of transaction control.

No check is made to determine if the mode change will damage data. No check is made if the new mode is valid.

Note: Use this method with caution as data may be lost. For instance, changing a data file from transaction processing to no transaction processing make automatic recovery unavailable.

CTTable.UpdatePadChar

Syntax

void UpdatePadChar(int Padchar, int Dmlchar, bool rebuild)

Parameters

  • Padchar [in] pad character
  • Dmlchar [in] field delimiter character
  • rebuild [in] - NOT YET IMPLEMENTED. Indicates if the table should be rebuilt. If rebuild is set to true, every record is read and the fixed string fields (FSTRING) are padded according to new padding strategy.

Description

Update the table pad and delimiter character resource. The table must be opened exclusive to allow update of the resource.

Return

None.

See Also

GetPadChar(), SetPadChar()