CTField Class

Description

The CTField class deals with the field concept. The field is the basic component of the table. Any table may be composed of as many fields as one needs. It uses CTBase as the base class, and implements the constructor/destructor allocating/freeing memory to the field operations.

See Also

CTBase, CTDatabase, CTSession, CTTable

Preconditions

Before any task is developed with a CTField object, a CTTable must have been initialized.

CTField Operators

  • = : Assign a CTField object to another

CTField.operator=

Syntax

CTField operator=( CTField Field)

Parameters

  • Field [in] The field object.

Description

Assigns one CTField object to another

Return

Returns a CTField object

CTField Methods

Constructor / Destructor

  • CTField(): Creates a CTField object
  • ~CTField(): Destroys a CTField object and resets all the dependent objects

Field Handling

  • GetLength(): Retrieves the field length
  • GetName(): Retrieves the field name
  • GetNullFlag(): Retrieves the field null flag
  • GetNumber(): Retrieves the field position index in the table field list
  • GetPrecision(): Retrieves the field precision
  • GetScale(): Retrieves the field scale
  • GetCTType(): Retrieves the field type
  • IsNumeric(): Indicates if the field represents a numeric value
  • SetLength(): Sets the field length
  • SetName(): Sets the field name
  • SetNullFlag(): Sets the new null flag value
  • SetPrecision(): Sets the field precision
  • SetScale(): Sets the field scale value
  • SetType(): Sets the field type

CTField.CTField

Syntax

CTField ( )

CTField( CTField Field)

Parameters

  • Field [in] The field object.

Description

This is the constructor for the CTField object.

See Also

~CTField()

CTField.~CTField

Syntax

~CTField

Parameters

This destructor has no parameters.

Description

This is the destructor for the CTField object.

See Also

CTField()

CTField.GetLength

Syntax

int GetLength( )

Parameters

This method has no parameters.

Description

Retrieves the field length.

Return

GetLength() retrieves the field length.

See Also

GetName(), GetType(), SetLength()

CTField.GetName

Syntax

String GetName( )

Parameters

This method has no parameters.

Description

Retrieves the field name.

Return

GetName() retrieves the field name.

See Also

GetLength(), GetType(), SetName()

CTField.GetNullFlag

Syntax

bool GetNullFlag( )

Parameters

This method has no parameters.

Description

Retrieves the field null flag.

The FairCom DB API null flag controls the NOT NULL property of a column. Setting this column has no effect on individual record null values: it is NOT enforced at the FairCom DB API layer. This attribute only applies to the FairCom DB SQL layer for constraint on values. It is useful to set this flag in c-tree data files before SQL import such that the property is maintained.

Return

GetNullFlag() returns the field null flag setting.

See Also

SetNullFlag()

CTField.GetNumber

Syntax

int GetNumber( )

Parameters

This method has no parameters.

Description

Retrieves the field position index in the table field list.

Return

GetNumber() returns the field number.

CTField.GetPrecision

Syntax

int GetPrecision( )

Parameters

This method has no parameters.

Description

Retrieves the field precision (maximum number of digits).

Return

GetPrecision() returns the field precision value.

See Also

SetPrecision()

CTField.GetScale

Syntax

int GetScale( )

Parameters

This method has no parameters.

Description

Retrieves the field scale (the number of digits to the right of the decimal point).

Return

GetScale() returns the field scale value.

See Also

SetScale()

CTField.GetStatus

Retrieves the changed status of a field object .

Declaration

ULONG CTField.GetStatus() const;

Description

CTField.GetStatus() retrieves the changed status of a field object. The status of a field object is a bit map describing one or more changes that have occurred with the field object.

Return

CTField.GetStatus returns a bitmap of the following:

Value

Symbolic Constant

Explanation

0x00

CTDBFIELD_OLD

Original field as read from table

0x01

CTDBFIELD_NEW

Field added or inserted

0x02

CTDBFIELD_DEL

Original field deleted

0x04

CTDBFIELD_MOVED

Original field moved

0x10

CTDBFIELD_NAME

Field name changed

0x20

CTDBFIELD_TYPE

Field type changed

0x40

CTDBFIELD_LEN

Field length changed

0x80

CTDBFIELD_RESOURCE

Field resource changed

Example


// if field is new delete it

for (i = 0; i < (NINT) hTable.GetFieldCount(); i++)

{

CTField hField = hTable.GetField(i);
 

if (hField.GetStatus() & CTDBFIELD_NEW)

hTable.DelField(i);

}
 

See Also

CTIndex.GetStatus(), CTSegment.GetStatus()

CTField.GetType

Syntax

FIELD_TYPE GetType( )

Parameters

This method has no parameters.

Description

Retrieves the field type.

Return

GetType() retrieves the field type.

See Also

GetLength(), GetName(), SetType()

CTField.IsNumeric

Syntax

bool IsNumeric( )

Parameters

This method has no parameters.

Description

Indicates if the field represents a numeric value.

Return

IsNumeric() returns true if the field is numeric.

See Also

SetNullFlag()

CTField.SetLength

Syntax

void SetLength(int Length)

Parameters

  • Length [in] The field length to be set to the field.

Description

Sets the field length

Return

None.

See Also

GetLength(), SetName(), SetType()

CTField.SetName

Syntax

void SetName(String FieldName)

Parameters

  • FieldName [in] The field name to be set to the field.

Description

Sets the field name.

Return

None.

See Also

GetName(), SetLength(), SetType()

CTField.SetNullFlag

Syntax

void SetNullFlag(bool flag)

Parameters

  • flag [in] The new null flag setting.

Description

Sets the new null flag value. The null flag indicates if the field can contain a null value.

The FairCom DB API null flag controls the NOT NULL property of a column. Setting this column has no effect on individual record null values: it is NOT enforced at the FairCom DB API layer. This attribute only applies to the FairCom DB SQL layer for constraint on values. It is useful to set this flag in c-tree data files before SQL import such that the property is maintained.

Return

None.

See Also

GetNullFlag()

CTField.SetPrecision

Syntax

void SetPrecision(int precision)

Parameters

  • precision [in] The new field precision.

Description

Sets the field precision (maximum number of digits).

Return

None.

See Also

GetPrecision()

CTField.SetScale

Syntax

void SetScale(int scale)

Parameters

  • scale [in] The new field scale value.

Description

Sets the field scale (the number of digits to the right of the decimal point).

Return

None.

See Also

GetScale()

CTField.SetType

Syntax

void SetType( FIELD_TYPE Type, int Length)

Parameters

  • Type [in] The field type to be set to the field. Valid type values are those defined in the FIELD_TYPE enum.
  • Length [in] The field length to be set to the field.

Description

Sets the field type.

Return

None.

See Also

GetType(), SetLength(), SetName()