C API Functions T

ctdbTableHasCallback

ctdbTableHasCallback () checks if there is at least one c-tree callback defined on the table.

Declaration

CTBOOL ctdbDECL ctdbTableHasCallback(CTHANDLE Handle)

Description

  • Handle - an active table handle

Returns

  • YES if at least one callback exists.
  • NO if no callback is present.

ctdbTableHasLocks

ctdbTableHasLocks() checks if any locks have been acquired by the current user on a table.

Declaration

CTBOOL ctdbDECL ctdbTableHasLocks(CTHANDLE Handle)

Description

  • Handle [IN] - Table handle

Check if any locks have been acquired on the table in the current session. This function uses the new the new ctCHK_ANYLOK LOKREC() mode.

Returns

Returns NO if no lock is present or failure (use ctdbGetError() to check), YES it there is at least one lock.

 

ctdbTDateTimeGetDate

Retrieve a CTDATE type value from a double containing a delphi TDateTime value.

Declaration

CTDBRET ctdbDECL ctdbTDateTimeGetDate(DOUBLE DateTime, pCTDATE pDate)

Description

ctdbTDateTimeGetDate() retrieves a CTDATE type value from a double containing a delphi TDateTime value.

Parameters:

  • DateTime [IN] - a double containing a delphi TDateTime value
  • pDate [OUT] - packed CTDATE type value

Return values

Returns CTDBRET_OK on success.

ctdbTDateTimeGetTimeMsec

Retrieve a CTTIMEMS type value from a double containing a delphi TDateTime value.

Declaration

CTDBRET ctdbDECL ctdbTDateTimeGetTimeMsec(DOUBLE DateTime, pCTTIMEMS pTime)

Description

ctdbTDateTimeGetTimeMsec() retrieves a CTTIMEMS type value from a double containing a delphi TDateTime value.

Parameters:

  • DateTime [IN] - a double containing a delphi TDateTime value
  • pTime [OUT] - packed CTTIMEMS type value

Return values

Returns CTDBRET_OK on success.

dbTDateTimeGetTime

Retrieve a CTTIME type value from a double containing a delphi TDateTime value.

Declaration

CTDBRET ctdbDECL ctdbTDateTimeGetTime(DOUBLE DateTime, pCTTIME pTime)

Description

ctdbTDateTimeGetTime() retrieves a CTTIME type value from a double containing a delphi TDateTime value.

Parameters:

  • DateTime [IN] - a double containing a delphi TDateTime value
  • pTime [OUT] - packed TIME type value

Return values

Returns CTDBRET_OK on success.

ctdbTDateTimeToDateTime

Convert a double containing a delphi TDateTime value into a CTDATETIME type value.

Declaration

CTDBRET ctdbDECL ctdbTDateTimeToDateTime(DOUBLE time, pCTDATETIME pDateTime)

Description

ctdbTDateTimeToDateTime() converts a double containing a delphi TDateTime value into a CTDATETIME type value.

Parameters:

  • time [IN] - a double containing a delphi TDateTime value
  • pDateTime [OUT] - CTDATETIME value

Return Values

Returns CTDBRET_OK on success.

 

ctdbTDateTimeToString

Convert a double containing a delphi TDateTime value to a string.

Declaration

CTDBRET ctdbDECL ctdbTDateTimeToString(DOUBLE time, CTDATE_TYPE DateType, CTTIME_TYPE TimeType, pTEXT pStr, VRLEN size)

Description

ctdbTDateTimeToString() converts a double containing a delphi TDateTime value to a string.

Parameters:

  • time [IN] - double containing a delphi TDateTime value
  • DateType [IN] - one of the date types
  • TimeType [IN] - one of the time types
  • pStr [out] - pointer to a string buffer to receive the converted date and time
  • size [IN] - size in bytes of the memory area pointed by pStr

Return values

Returns CTDBRET_OK on success.

ctdbTimeCheck

Check if the given time is valid.

Declaration

CTDBRET ctdbTimeCheck(NINT hour, NINT minute, NINT second)

Description

ctdbTimeCheck() checks to see if the given time is valid. To check if the date is valid, use ctdbDateCheck().

  • hour is the hour, and it is supposed to be in the range 0 ≤ hour ≤ 23
  • minute is the minute, and it is supposed to be in the range 0 ≤ minute ≤ 59
  • second is the second, and it is supposed to be in the range 0 ≤ minute ≤ 59

Returns

ctdbTimeCheck() returns CTDBRET_OK on success, or FairCom DB API C API error code on failure.

The possible errors associated with ctdbTimeCheck() are:

  • CTDBRET_INVHOUR (4034): Invalid hour
  • CTDBRET_INVMINUTE (4035): Invalid minute
  • CTDBRET_INVSECOND (4036): Invalid second

See also

ctdbDateCheck()

ctdbTimeMsecToString

Convert a packed CTTIMEMS into a string with millisecond precision.

NOTE: See ctdbTimeToString() if you don't need millisecond precision.

Declaration

CTDBRET ctdbDECL ctdbTimeMsecToString(CTTIMEMS Time, CTTIME_TYPE TimeType, pTEXT pStr, VRLEN size)

Parameters:

  • Time [IN] - The Time value to convert
  • TimeType [IN] - One of the time types
  • pStr [OUT] - Time in string format
  • size [IN] - Size of the Time parameter

Description

FairCom DB API function to convert a timems value (time with milliseconds) to a string.

V11.5 and later support the CTTIME_HMST time format: Time is h|hh:mm:ss.ttt (24-hour time; t is milliseconds). The millisecond portion is optional, if missing it defaults to 0.

This function supports the CTTIME_HHMST mode, which forces the hour to be two digits and returns time as hh:mm:ss.ttt (24 hour).

Return Values

Return CTDBRET_OK on success.

Value

Symbolic Constant

Explanation

0

CTDBRET_OK

Successful operation.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

See Also

ctdbStringToTimeMsec(), ctdbStringToTime(), ctdbTimeToString()

ctdbTimePack

Convert a time in the form hour, minute, second into a CTTIME form with whole second precision.

Note "See ctdbTimePackMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbTimePack(pCTTIME pTime, NINT hour, NINT minute,
                     NINT second)

Description

ctdbTimePack() pack a time in the form hour:minute:second into a CTTIME form.

  • pTime [out] the packed time.
  • hour [in] the hour.
  • minute [in] the minute.
  • second [in] the second

Returns

ctdbTimePack() returns CTDBRET_OK on success, or FairCom DB API C API error on failure.

See also

ctdbTimeUnpack(), ctdbDateTimePack(), ctdbTimePackMsec(), ctdbTimeUnpackMsec()

 

ctdbTimePackMsec

Convert a time in the form hour, minute, second, millisec into a CTTIMEMS form with millisecond precision.

Note See ctdbTimePack() if you don't need millisecond precision.

Declaration

CTDBRET ctdbDECL ctdbTimePackMsec(pCTTIMEMS pTime, NINT hour, NINT minute, NINT second, NINT millisec)

Parameters:

  • pTime [OUT] - Packed CTTIMEMS
  • hour [IN]
  • minute [IN]
  • second [IN]
  • millisec [IN]

Description

ctdbTimePackMsec() packs a time in the form hour:minute:second:millisec into a CTTIMEMS form.

Return Values

Value Symbolic Constant Explanation
0 CTDBRET_OK Successful operation.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

 See Also

ctdbGetFieldAsTimeMsec, ctdbSetFieldAsTimeMsec, ctdbTimePack(), ctdbTimeUnpack(), ctdbTimePackMsec, ctdbTimeUnpackMsec, ctdbDateTimeSetTimeMsec, ctdbDateTimeGetTimeMsec, ctdbDateTimePackMsec, ctdbDateTimeUnpackMsec

 

ctdbTimeToString

Convert a packed CTTIME into a string with whole second precision.

Note See ctdbTimeMsecToString() if you need millisecond precision.

Declaration

CTDBRET ctdbTimeToString(CTTIME Time, CTTIME_TYPE TimeType,
                         pTEXT pStr, VRLEN size)

Description

ctdbTimeToString() converts a packed CTTIME into a string. To convert a packed CTTIME to seconds, use ctdbTimeToSeconds(). Use ctdbStringToTime() to convert from a string to CTTIME. Use ctdbDateToString() to convert a packed CTDATE into a string.

  • Time [in] the time, in CTTIME format.
  • TimeType [in] the time type. Valid types are listed in FairCom DB API Data Types.
  • pStr [out] the pointer to the string that will result from the conversion.
  • size [in] the buffer size of the string.

Returns

ctdbTimeToString() returns CTDBRET_OK on success, or FairCom DB API C API error on failure.

The possible errors associated with ctdbTimeToString() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_INVFORMAT (4028): Invalid format in TimeType
  • CTDBRET_ARGSMALL (4006): Buffer is too small (increase size)

See also

ctdbTimeToSeconds(), ctdbStringToTime(), ctdbStringToTimeMsec(), ctdbTimeMsecToString(), ctdbDateToString(), ctdbDateTimeToString()

 

ctdbTimeUnpack

Convert a CTTIME time into the form hour, minute, second with whole second precision.

Note See ctdbTimeUnpackMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbTimeUnpack(CTTIME Time, pNINT pyear, pNINT pmonth,
                       pNINT pday)

Description

ctdbTimeUnpack() unpack a CTTIME time into the form day, month and year.

  • Time [in] the packed time.
  • phour [out] the hour.
  • pminute [out] the minute
  • psecond [out] the second

Returns

ctdbTimeUnpack() returns CTDBRET_OK on success, or FairCom DB API C API error on failure.

See also

ctdbTimePack(), ctdbTimePackMsec(), ctdbTimeUnpackMsec()

 

ctdbTimeUnpackMsec

Convert a CTTIMEMS into hour, minute, second, and millisecond.

Note See ctdbTimeUnpack() if you don't need millisecond precision.

Declaration

CTDBRET ctdbDECL ctdbTimeUnpackMsec(CTTIMEMS Time, pNINT phour, pNINT pminute, pNINT psecond, pNINT pmillisec)

Parameters:

  • Time [IN] - Packed CTTIMEMS
  • hour [OUT]
  • minute [OUT]
  • second [OUT]
  • millisec [OUT]

Description

ctdbTimeUnpackMsec() unpacks a CTTIMEMS into hour, minute, second, and millisecond values.

Return Values

Value Symbolic Constant Explanation
0 CTDBRET_OK Successful operation.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

 

See Also

ctdbGetFieldAsTimeMsec, ctdbSetFieldAsTimeMsec, ctdbTimePackMsec, ctdbTimePack(), ctdbTimeUnpack(), ctdbDateTimeSetTimeMsec, ctdbDateTimeGetTimeMsec, ctdbDateTimePackMsec, ctdbDateTimeUnpackMsec

ctdbTruncateTable

Removes all records from an existing table.

Declaration

ctdbEXPORT CTDBRET ctdbDECL ctdbTruncateTable(CTHANDLE Handle);

Description

  • Handle - open table handle.

ctdbTruncateTable() truncates a data file, meaning a new copy of the file is created with no data records. File properties and resources are preserved. The function closes the table, truncates it, and reopens it. Return value of CTDBRET_OK indicates success.

Limitations

Requires data file to have an IFIL resource; otherwise, the function call fails with error RNOT_ERR (408, resource not found).