Class CTField
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the current field's default value.void
Sets the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values.int
Retrieves theFIELD_TYPE
.int
Retrieves the field binary handling flag.int
Retrieves the default valueDATE_TYPE
used when converting strings to dates.int
Retrieves the default valueTIME_TYPE
used when converting String to time.Retrieves the current field default value.Get the field string encoding.int
Retrieves the field length.GetName()
Retrieves the field name.boolean
Retrieves the field null flag.int
Retrieves the field position index in theCTTable
field list.int
Retrieves the field precision.int
GetScale()
Retrieves the field scale.int
Retrieves the status of a field handle.int
GetType()
Retrieves theFIELD_TYPE
.boolean
Checks if a field default value has been set.boolean
Checks if the field represents a numeric value.void
SetFieldBinaryFlag
(int Flag) Sets the value of the field binary handling flag.void
SetFieldDefaultDateTimeType
(int DateType, int TimeType) Sets the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values.void
SetFieldDefaultValue
(String Value) Sets the field default value.void
SetFieldStringEncoding
(String encoding) Set the field string encoding.void
SetLength
(int FieldLength) Sets the field length.void
Sets the field name.void
SetNullFlag
(boolean flag) Sets Null Flag.void
SetPrecision
(int precision) Sets the field precision.void
SetScale
(int scale) Sets the field scale value.void
SetType
(int FieldType, int FieldLength) Sets the fieldFIELD_TYPE
and length.Methods inherited from class CTBase
Abort, Begin, ClearSavePoint, Commit, GetAutoCommit, GetHandle, GetKeepLock, GetLockMode, GetOperation, GetTransactionMode, IsLockActive, IsTransActive, IsUnicodeLib, Lock, PrepareCommit, RestoreSavePoint, SetAutoCommit, SetHandle, SetKeepLock, SetOperation, SetSavePoint, SetTransactionMode, Unlock
-
Constructor Details
-
CTField
public CTField()Default constructor for the CTField class.- See Also:
-
CTField
Copy constructor for the CTField class.- Parameters:
Field
- CTField object to be copied.- See Also:
-
-
Method Details
-
GetName
Retrieves the field name.- Returns:
- Field name
- See Also:
-
GetType
public int GetType()Retrieves theFIELD_TYPE
.- Returns:
- Current
FIELD_TYPE
value. - See Also:
-
GetCTType
public int GetCTType()Retrieves theFIELD_TYPE
. Maintained for backward compatibility.- Returns:
- Current
FIELD_TYPE
value. - See Also:
-
GetLength
public int GetLength()Retrieves the field length.- Returns:
- Current field length.
- See Also:
-
SetName
Sets the field name.- Parameters:
FieldName
- New field name value.- Throws:
CTException
- in case of error- See Also:
-
SetType
Sets the fieldFIELD_TYPE
and length.- Parameters:
FieldType
- NewFIELD_TYPE
for the Field.FieldLength
- New length for the Field.- Throws:
CTException
- in case of error- See Also:
-
SetLength
Sets the field length.- Parameters:
FieldLength
- New length for the Field.- Throws:
CTException
- in case of error- See Also:
-
GetNumber
Retrieves the field position index in theCTTable
field list.- Returns:
- Field position.
- Throws:
CTException
- in case of error- See Also:
-
GetNullFlag
public boolean GetNullFlag()Retrieves the field null flag.- Returns:
- true if field is null, or false if it is not null.
- See Also:
-
GetPrecision
public int GetPrecision()Retrieves the field precision.- Returns:
- Current field precision value.
- See Also:
-
GetScale
public int GetScale()Retrieves the field scale.- Returns:
- Current field scale value.
- See Also:
-
SetNullFlag
Sets Null Flag.- Parameters:
flag
- New field null flag. True if field is null, or false if it is not.- Throws:
CTException
- in case of error- See Also:
-
SetPrecision
Sets the field precision.- Parameters:
precision
- New field precision value.- Throws:
CTException
- in case of error- See Also:
-
SetScale
Sets the field scale value.- Parameters:
scale
- New field scale value.- Throws:
CTException
- in case of error- See Also:
-
IsNumeric
public boolean IsNumeric()Checks if the field represents a numeric value.- Returns:
- true if field is numeric or false if it is not.
- See Also:
-
SetFieldDefaultValue
Sets the field default value. The default value of a field is used during an alter table operation when a full table rebuild is performed. During a full alter table rebuild, and after the old record buffer data is moved to the new record buffer, the new record buffer is scanned and if a null field is found and that null field has a default value, the default value is copied to the field buffer.The field default value is kept as a String representation of the data. It is recommended that numeric data should be converted to String using one of the rich set of c-treeDB data conversion functions.
Date values should be converted to String using the default date type value. The default date type value can be retrieved by calling
GetFieldDefaultDateType()
method. By default, the date type is CTDATE_MDCY.Time values should be converted to String using the default time type value. The default time type value can be retrieved by calling
GetFieldDefaultTimeType()
function. By default, the time type is CTTIME_HMS.Time stamp values should be converted to String using the default date type and time type values as described above.
- Parameters:
Value
- New field default value.- Throws:
CTException
- in case of error- See Also:
-
GetFieldDefaultValue
Retrieves the current field default value. If no default value is set, GetFieldDefaultValue return zero. You can useIsFieldDefaultValueSet()
method to check if a field default value is set or not.- Returns:
- Current field default value.
- See Also:
-
ClearFieldDefaultValue
Clears the current field's default value. The default date and time types are also reset to their default values of CTDATE_MDCY and CTTIME_HMS respectively.- Throws:
CTException
- in case of error- See Also:
-
CTFieldSetFieldDefaultDateTimeType
Sets the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values. By default the date type is CTDATE_MDCY and the time type is CTTIME_HMS. Use this method to modify the default values.- Throws:
CTException
- in case of error- See Also:
-
SetFieldDefaultDateTimeType
Sets the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES String values. By default the date type is CTDATE_MDCY and the time type is CTTIME_HMS. Use this method to modify the default values.SetFieldDefaultDateTimeType method modifies both the date and time types. If you wish to change only the default date time, but keep the current time type, use the following example:
hField.SetFieldDefaultDateTimeType(CTDATE_YMD, hField.GetFieldDefaultTimeType());
You can use the same approach to change only the time type, keeping the current date type:
hField.SetFieldDefaultDateTimeType( ctdbGetFieldDefaultDateType(), CTIME_HMP);
- Parameters:
DateType
- NewDATE_TYPE
field value.TimeType
- NewTIME_TYPE
field value.- Throws:
CTException
- in case of error- See Also:
-
IsFieldDefaultValueSet
public boolean IsFieldDefaultValueSet()Checks if a field default value has been set.- Returns:
- true if a field default value was set, or false if it was not.
- See Also:
-
GetFieldDefaultDateType
public int GetFieldDefaultDateType()Retrieves the default valueDATE_TYPE
used when converting strings to dates.- Returns:
- Current
DATE_TYPE
default value. - See Also:
-
GetFieldDefaultTimeType
public int GetFieldDefaultTimeType()Retrieves the default valueTIME_TYPE
used when converting String to time.- Returns:
- Current
TIME_TYPE
default value - See Also:
-
GetStatus
public int GetStatus()Retrieves the status of a field handle. The status of a field handle is a bit map describing one or moreFIELD_STATUS
values.- Returns:
- Current
FIELD_STATUS
value. - See Also:
-
GetFieldBinaryFlag
public int GetFieldBinaryFlag()Retrieves the field binary handling flag. The fieldBINARY_FLAG
indicates how c-treeDB will handle CT_ARRAY, CT_F2STRING, and CT_2STRING fields.- Returns:
- Current field
BINARY_FLAG
value. - See Also:
-
SetFieldBinaryFlag
Sets the value of the field binary handling flag. The fieldBINARY_FLAG
indicates how c-treeDB will handle CT_ARRAY, CT_F2STRING and CT_2STRING fields.- Parameters:
Flag
- New fieldBINARY_FLAG
value.- Throws:
CTException
- in case of error- See Also:
-
SetFieldStringEncoding
Set the field string encoding.- Parameters:
encoding
- a string describing the encoding used in the field content. CTDB does not enfore any check on the value passed in, yet JTDB, JDBC, Ado .Net provider and SQL server expect to be able to identify the encoding therefore use values as defined by IANA https://www.iana.org/assignments/character-sets/character-sets.xhtml- Throws:
CTException
- in case of error- See Also:
-
GetFieldStringEncoding
Get the field string encoding.- Returns:
- Field string encoding value
- Throws:
CTException
- in case of error
-