C API Functions D

ctdbDateCheck

Check if a given date is valid.

Declaration

CTDBRET ctdbDateCheck(NINT year, NINT month, NINT day)

Description

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

  • year [in] the year, and it is supposed to be ≥ 0.
  • month [in] the month, and it supposed to be in the range 1 ≤ month ≤ 12.
  • day [in] the day, and it supposed to be in the range 1 ≤ day ≤ 28, or 29, or 30, or 31, depending on the month and year.

Returns

ctdbDateCheck() returns CTDBRET_OK if date is ok, or FairCom DB API error on failure.

The possible errors associated with ctdbDateCheck() are:

  • CTDBRET_INVYEAR (4032): Invalid year
  • CTDBRET_INVMONTH (4031): Invalid month
  • CTDBRET_INVDAY (4030): Invalid day

See also

ctdbTimeCheck()

 

ctdbDatePack

Pack a date in the form day, month and year into a CTDATE form.

Declaration

CTDBRET ctdbDatePack(pCTDATE pDate, NINT year, NINT month, NINT day)

Description

ctdbDatePack() pack a date in the form day, month and year into a CTDATE form.

  • pDate [out] the packed date.
  • year [in] the year, and it is supposed to be ≥ 0.
  • month [in] the month, and it supposed to be in the range 1 ≤ month ≤ 12.
  • day [in] the day, and it supposed to be in the range 1 ≤ day ≤ 28, or 29, or 30, or 31, depending on the month and year.

Returns

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

See also

ctdbDateUnpack(), ctdbDateTimePack()

 

ctdbDateTimeGetDate

Retrieve a CTDATE type value from a CTDATETIME type value

Note See ctdbDateTimeGetDateMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimeGetDate(CTDATETIME DateTime, pCTDATE pDATE)

Description

ctdbDateTimeGetDate() retrieves a CTDATE type value from a CTDATETIME type value.

  • DateTime [in] the packed date and time value.
  • pDate [out] the CTDATE value.

Returns

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

See also

ctdbDateTimeSetDate(), ctdbDateTimeGetTime(), ctdbDateTimeGetTimeMsec

 

ctdbDateTimeGetTime

Retrieve a CTTIME type value from a CTDATETIME type value with whole second precision.

Note See ctdbDateTimeGetTimeMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimeGetTime(CTDATETIME DateTime, pCTTIME pTIME)

Description

ctdbDateTimeGetTime() retrieves a CTTIME type value from a CTDATETIME type value.

  • DateTime [in] the packed date and time value.
  • pTime [out] the CTTIME value.

Returns

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

See also

ctdbDateTimeGetDate(), ctdbDateTimeSetTime(), ctdbDateTimeGetTimeMsec().

 

ctdbDateTimeGetTimeMsec

Retrieve a CTTIMEMS type value from a CTDATETIME type value.

Note See ctdbDateTimeGetTime() if you do not need millisecond precision.

Declaration

CTDBRET ctdbDECL ctdbDateTimeGetTimeMsec(CTDATETIME DateTime, pCTTIMEMS pTime)

Parameters:

  • DateTime [IN] - Packed CTDATETIME type value
  • pTime [OUT] - Packed CTTIMEMS type value

Description

ctdbDateTimeGetTimeMsec() retrieves a CTTIMEMS type value from a CTDATETIME type value.

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, ctdbTimeUnpackMsec, ctdbDateTimeSetTimeMsec, ctdbDateTimePackMsec, ctdbDateTimeUnpackMsec, ctdbDateTimeGetTime

 

ctdbDateTimePack

Convert a date and time in the form day, month, year, hour, minute, second into a CTDATETIME form.

Note See ctdbDateTimePackMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimePack(pCTDATETIME pDateTime, NINT year, NINT
            month, NINT day, NINT hour, NINT minute, NINT second)

Description

ctdbDateTimePack() pack a date and time value in the form day, month, year, hour, minute, second into a CTDATETIME form.

  • pDateTime [out] the packed date and time value.
  • year [in] the year.
  • month [in] the month.
  • day [in] the day.
  • hour [in] the hour.
  • minute [in] the minute.
  • second [in] the second.

Returns

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

See also

ctdbDateTimeUnpack(), ctdbDateTimePackMsec(), ctdbDateTimeUnpackMsec()

 

ctdbDateTimePackMsec

Convert a date and time in the form day, month, year, hour, minute, second, millisec into a CTDATETIME form.

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

Declaration

CTDBRET ctdbDECL ctdbDateTimePackMsec(pCTDATETIME pDateTime, NINT year, NINT month, NINT day, NINT hour, NINT minute, NINT second, NINT millisec)

Parameters:

  • pDateTime [OUT] - Packed CTDATETIME value
  • year [IN]
  • month [IN]
  • day [IN]
  • hour [IN]
  • minute [IN]
  • second [IN]
  • millisecond [IN]

Description

ctdbDateTimePackMsec() packs a CTDATETIME type value with millisecond precision.

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, ctdbTimeUnpackMsec, ctdbDateTimeSetTimeMsec, ctdbDateTimeGetTimeMsec, ctdbDateTimeUnpackMsec, ctdbDateTimePack ,ctdbDateTimeUnpack

 

ctdbDateTimeSetDate

Set a CTDATETIME type value with a CTDATE type value.

Note See ctdbDateTimeSetDateMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimeSetDate(pCTDATETIME pDateTime, CTDATE DATE)

Description

ctdbDateTimeSetDate() sets a CTDATETIME type value with a CTDATE type value. The time component of the CTDATETIME type value is left unchanged.

  • pDateTime [in/out] the packed date and time value.
  • Date [in] the CTDATE value.

Returns

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

See also

ctdbDateTimeGetDate(), ctdbDateTimeSetTime(), ctdbDateTimeSetTimeMsec

 

ctdbDateTimeSetTime

Set a CTDATETIME type value with a CTTIME type value with whole second precision.

Note See ctdbDateTimeSetTimeMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimeSetTime(pCTDATETIME pDateTime, CTTIME TIME)

Description

ctdbDateTimeSetTime() sets a CTDATETIME type value with a CTTIME type value. The date component of the CTDATETIME type value is left unchanged.

  • pDateTime [in/out] the packed date and time value.
  • Time [in] the CTTIME value.

Returns

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

See also

ctdbDateTimeSetDate(), ctdbDateTimeGetTime(), ctdbDateTimeSetTimeMsec()

 

ctdbDateTimeSetTimeMsec

Set a CTDATETIME value with a CTTIMEMS type value with millisecond precision.

Note See ctdbDateTimeSetTime() if you do not need millisecond precision.

Declaration

CTDBRET ctdbDECL ctdbDateTimeSetTimeMsec(pCTDATETIME pDateTime, CTTIMEMS Time)

Parameters:

  • pDateTime [IN/OUT] - Packed CTDATETIME type value
  • Time [IN] - Packed CTTIMEMS type value

Description

ctdbDateTimeSetTimeMsec() sets a CTDATETIME type value with a CTTIMEMS type value. The date component of the CTDATETIME type value is left unchanged.

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, ctdbTimeUnpackMsec, ctdbDateTimeSetTime, ctdbDateTimeGetTimeMsec, ctdbDateTimePackMsec, ctdbDateTimeUnpackMsec

 

ctdbDateTimeToString

Convert a packed CTDATETIME into a string including milliseconds.

Declaration

CTDBRET ctdbDateTimeToString(CTDATETIME DateTime, CTDATE_TYPE
              DateType, CTTIME_TYPE TimeType, pTEXT pStr, VRLEN size)

Description

ctdbDateTimeToString() converts a packed CTDATETIME into a string. The date is converted to string based on the DateType parameter, and the time is converted to string based on the TimeType parameter.

  • DateTime [in] the date and time, in CTDATETIME format.
  • DateType [in] the date type. Valid types are listed in FairCom DB API Data Types.
  • TimeType [in] the time type. Valid types are listed inFairCom DB API Data Types.
  • pStr [out] a pointer to the string that will result from the conversion.
  • size [in] the buffer size for the string.

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).

Returns

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

The possible errors associated with ctdbDateTimeToString() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_INVDATE (4029): Invalid format in DateType
  • CTDBRET_INVTYPE (4019): Invalid type in DateType or TimeType
  • CTDBRET_ARGSMALL (4006): Buffer is too small (increase size)

See also

ctdbTimeToString(), ctdbDateToString(), ctdbStringToDateTime()

 

ctdbDateTimeToTDateTime

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

Declaration

CTDBRET ctdbDECL ctdbDateTimeToTDateTime(CTDATETIME DateTime, DOUBLE* time)

Description

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

Parameters:

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

Return Values

Returns CTDBRET_OK on success.

 

ctdbDateTimeToUnixTime

Convert a CTDATETIME type value into a time_t unix epoch value.

Declaration

CTDBRET ctdbDECL ctdbDateTimeToUnixTime(CTDATETIME DateTime, time_t* time, CTBOOL fromlocaltime)

Description

ctdbDateTimeToUnixTime() convert a CTDATETIME type value into a time_t unixtime value.

Parameters:

  • DateTime [IN] - CTDATETIME value
  • time[OUT] - time_t
  • fromlocaltime [IN] - convert from localtime

Return Values

Return CTDBRET_OK on success

 

ctdbDateTimeUnpack

Convert a date and time in CTDATETIME form into the form day, month, year, hour, minute, second with whole second precision.

Note See ctdbDateTimeUnpackMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbDateTimeUnpack(CTDATETIME DateTime, pNINT pYear, pNINT pMonth, pNINT pDay, pNINT pHour, pNINT pMinute, pNINT pSecond)

Description

ctdbDateTimeUnpack() unpacks a date and time CTDATETIME value into the form day, month, year, hour, minute, second.

  • DateTime [in] the packed date and time value.
  • pyear [out] the year.
  • pmonth [out] the month.
  • pday [out] the day.
  • phour [out] the hour.
  • pminute [out] the minute.
  • psecond [out] the second.

Returns

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

See also

ctdbDateTimePack(), ctdbDateTimeUnpackMsec(), ctdbDateTimePackMsec()

 

ctdbDateTimeUnpackMsec

Convert a date and time in CTDATETIME form into the form day, month, year, hour, minute, second, millisecond.

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

Declaration

CTDBRET ctdbDECL ctdbDateTimeUnpackMsec(CTDATETIME DateTime, pNINT pYear, pNINT pMonth, pNINT pDay, pNINT pHour, pNINT pMinute, pNINT pSecond, pNINT pMillisec)

Parameters:

  • DateTime [IN] - Packed CTDATETIME type value
  • pYear [OUT]
  • pMonth [OUT]
  • pDay [OUT]
  • pHour [OUT]
  • pMinute [OUT]
  • pSecond [OUT]
  • pMillisec [OUT]

Description

ctdbDateTimeUnpackMsec() unpacks a CTDATETIME type value with millisecond precision.

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, ctdbTimeUnpackMsec, ctdbDateTimeSetTimeMsec, ctdbDateTimeGetTimeMsec, ctdbDateTimePackMsec, ctdbDateTimeUnpack, ctdbDateTimePack

 

ctdbDateToString

Convert a packed CTDATE into a string.

Declaration

CTDBRET ctdbDateToString(CTDATE date, CTDATE_TYPE DateType,
                         pTEXT pStr, VRLEN size)

Description

ctdbDateToString() converts a packed CTDATE into a string. The date is converted to string based on the DateType parameter. To convert a packed CTTIME to string, use ctdbTimeToString(). Use ctdbStringToDate() to convert from a string to CTDATE.

  • date [in] the date, in CTDATE format.
  • DateType [in] the date type. Valid types are listed in FairCom DB API Data Types.
  • pStr [in] the pointer to the string that will result from the conversion.
  • size [in] the buffer size of the string.

Returns

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

The possible errors associated with ctdbDateToString() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_INVDATE (4029): Invalid format in DateType
  • CTDBRET_INVTYPE (4019): Invalid type in DateType
  • CTDBRET_ARGSMALL (4006): Buffer is too small (increase size)

See also

ctdbStringToDate(), ctdbTimeToString(), ctdbDateTimeToString()

 

ctdbDateUnpack

Unpack a CTDATE date into the form day, month and year.

Declaration

CTDBRET ctdbDateUnpack(CTDATE Date, pNINT pyear, pNINT pmonth, pNINT pday)

Description

ctdbDateUnpack() unpacks a CTDATE date into the form day, month and year.

  • Date [in] the packed date.
  • pyear [out] the year.
  • pmonth [out] the month.
  • pday [out] the day

Returns

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

See also

ctdbDatePack()

 

ctdbDayOfWeek

Retrieve the day of the week from a packed CTDATE.

Declaration

NINT ctdbDayOfWeek(CTDATE date)

Description

ctdbDayOfWeek() retrieves the number of the day of the week from a packed CTDATE. Sunday is 0, Monday is 1, Tuesday is 2, Wednesday is 3, Thursday is 4, Friday is 5 and Saturday is 6. To retrieve the day of the month, use ctdbGetDay().

  • date [in] the date, in CTDATE format.

Returns

ctdbDayOfWeek() returns the number of the day of the week, or -1 on error.

See also

ctdbGetDay()

 

ctdbDeleteDatabase

Drop the database from session and delete database file and index.

Declaration

CTDBRET ctdbDeleteDatabase(CTHANDLE Handle, cpTEXT Name)

Description

ctdbDeleteDatabase() drops the database from the session dictionary and deletes the database file and index.

  • Handle [in] - the handle of the session that contains the database to be dropped.
  • Name [in] - the database name.

Use ctdbAddDatabase() to add a database to a session. Use ctdbDropDatabase() to drop the database from the session dictionary without deleting the database files.

Returns

ctdbDeleteDatabase() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example

eRet = ctdbLogon(hSession, "FAIRCOMS", "ADMIN", "ADMIN");
eRet = ctdbDeleteDatabase(hSession, database_name);

See also:
ctdbAllocSession(), ctdbAddDatabase(), ctdbDropDatabase()

ctdbDeleteRecord

Delete an existing record.

Declaration

CTDBRET ctdbDeleteRecord(CTHANDLE Handle)

Description

ctdbDeleteRecord() deletes an existing record from a table. While not enforced by the FairCom DB API API, it is strongly recommended that a WRITE_LOCK be acquired on the record before it is deleted by calling this function. To lock the record, use either session-wide record locking (ctdbLock()) or manually lock the record by calling ctdbdbLockRecord().

Once a record has been deleted, FairCom DB API automatically releases any locks that were held by that record. Outside of a transaction, the locks are released before the ctdbDeleteRecord() function returns. Inside a transaction, the locks are held until the transaction is ended (the ctdbCommit() or the ctdbAbort() function returns).

Note that if the table was opened in CTOPEN_CHECKLOCK or CTOPEN_CHECKREAD mode (see ctdbOpenTable()), then the corresponding locks must be obtained before the record is read / deleted.

  • Handle [in] the record handle.

Returns

ctdbDeleteRecord() returns CTDBRET_OK if successful, or the c-tree error code on failure.

See also

ctdbAllocRecord(), ctdbLock(), ctdbdbLockRecord(), ctdbReadRecord(), ctdbWriteRecord()

 

ctdbDeleteResource

Delete an existing resource from a table.

DECLARATION

  CTDBRET ctdbDECL ctdbDeleteResource(CTHANDLE resource);

DESCRIPTION

ctdbDeleteResource() delete a resource from a table. Before a resource can be deleted, the table must be opened exclusive. The resource type and resource number that identify this resource must be passed to ctdbAllocResource(). Resource is a handle allocated by ctdbAllocResource().

RETURN

ctdbDeleteResource() returns CTDBRET_OK on success

EXAMPLE


/* delete a resource */

CTDBRET DelMyResource(CTHANDLE Handle, ULONG type, ULONG number, pTEXT name)

{

CTDBRET Retval;

CTHANDLE hRes = ctdbAllocResource(Handle, type, number, name);

 

if (hRes)

{

if ((Retval = ctdbDeleteResource(hRes)) != CTDBRET_OK)

printf("ctdbDeleteResource failed with error %d\n", Retval);

 

ctdbFreeResource(hRes);

}

else

{

printf("Failed to allocate resource handle\n");

Retval = CTDBRET_NOMEMORY;

}

return Retval;

}

SEE ALSO

ctdbAllocResource(), ctdbFreeResource(), ctdbAddResource(), ctdbFirstResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUpdateResource(), ctdbUnlockResource()

 

ctdbDeleteTable

Drop a table from a database and delete its data and index files from disk.

Declaration

CTDBRET ctdbDeleteTable(CTHANDLE Handle, pTEXT TableName, pTEXT Password)

Description

ctdbDeleteTable() drops the table from the database and deletes the table data and index files from disk. This function should be used with care, since it will remove from disk the data and index file(s) associated with the specified table. Note that active/open tables must be closed before they can be deleted with this function (see ctdbCloseTable()).

Handle [in] the handle of the database that contains the table to be deleted.
TableName [in] the name of the table to be deleted.
Password [in] the table password. NULL if the table was created w/o a password.
Use ctdbAddTable() to add a table to a database. Use ctdbDropTable() to drop the table from the database but not delete the table files from disk.

Note ctdbDeleteTable() is for use within a CTDB or SQL session. For a CTREE session, you must use ctdbRemoveTable(). See also Allocating a Session Handle.

Returns

ctdbDeleteTable() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


eRet=ctdbConnect(hDatabase, database_name);
eRet = ctdbDeleteTable(hDatabase, table_name, NULL);

See also

ctdbAddTable(), ctdbDropTable(), ctdbAllocDatabase()

 

ctdbDelField

Delete the field indicated by the field number index from a table.

Declaration

CTDBRET ctdbDelField(CTHANDLE Handle, NINT Index)

Description

ctdbDelField() deletes the field indicated by the field number Index from a table. Note that any fields with higher field numbers than the one you deleted will have one subtracted from their field numbers in order to fill the gap left by the field you deleted. Use ctdbDelFieldByName() to delete a field by name. Use ctdbAddField(), ctdbInsField() and ctdbInsFieldByName() to add fields to a table.

  • Handle [in] the Table handle.
  • Index [in] the field number to be deleted.

Returns

ctdbDelField() returns CTDBRET_OK on success or FairCom DB API error code on failure.

See also

ctdbAllocTable(), ctdbAddField(), ctdbInsField(), ctdbInsFieldByName(), ctdbDelFieldByName(), ctdbMoveField()

 

ctdbDelFieldByName

Delete the field indicated by the field name from a table.

Declaration

CTDBRET ctdbDelFieldByName(CTHANDLE Handle, pTEXT FieldName)

Description

ctdbDelFieldByName() deletes the field indicated by the field name from a table. Note that any fields with higher field numbers than the one you deleted will have one subtracted from their field numbers to fill the gap left by the field you deleted. Use ctdbDelField() to delete a field by number. Use ctdbAddField(), ctdbInsField() and ctdbInsFieldByName() to add fields to a table.

  • Handle [in] the Table handle.
  • FieldName [in] the name of the field to be deleted.

Returns

ctdbDelFieldByName() returns CTDBRET_OK on success or FairCom DB API error code on failure.

See also

ctdbAllocTable(), ctdbAddField(), ctdbInsField(), ctdbInsFieldByName(), ctdbDelField(), ctdbMoveField()

 

ctdbDelIndex

Delete an index from a table.

Declaration

CTDBRET ctdbDelIndex(CTHANDLE Handle, NINT IndexNumber)

Description

ctdbDelIndex() deletes an index from a table. Use ctdbAddIndex() to add indexes in a table.

  • Handle [in] - the table handle.
  • IndexNumber [in] - the number of the index in the table.

Returns

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

See also

ctdbAllocTable(), ctdbAddIndex()

ctdbDelSegment

Delete segment indicated by SegNumber.

Declaration

CTDBRET ctdbDelSegment(CTHANDLE Handle, NINT SegNumber)

Description

ctdbDelSegment() deletes a segment from an index. The segment to be deleted is indicated by SegNumber. Use ctdbAddSegment() and ctdbInsSegment() to add new index segments.

  • Handle [in] the index handle.
  • SegNumber [in] the index segment number to be deleted.

Returns

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

See also

ctdbAllocIndex(), ctdbAddSegment(), ctdbInsSegment()

ctdbDelSegmentEx

Delete extended segment.

Declaration

CTDBRET ctdbDelSegmentEx(CTHANDLE Handle)

Description

ctdbDelSegmentEx() deletes an extended segment from an index.

  • Handle [in] the segment handle.

Returns

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

See also

ctdbDelSegment()

 

ctdbDetachTable

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

DECLARATION

CTDBRET ctdbDetachTable(CTHANDLE Handle);

DESCRIPTION

ctdbDetachTable() detaches a FairCom DB API table handle from a c-tree data and index files. The table is not closed but the FairCom DB API table handle resources are released and the handle re-initialized. Handle is a FairCom DB API table handle allocated by ctdbAllocTable().

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

EXAMPLE

CTHANDLE hSession = ctdbAllocSession(CTSESSION_CTREE);

CTHANDLE hTable = ctdbAllocTable(hSession);

CTHANDLE hRecord = ctdbAllocRecord(hTable);

NINT datno, count = 0;


/* logon to c-tree */

ctdbLogon(hSession, SERVER, USER, PASSWD);


/* open the file using c-tree ISAM */

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


/* attach to table */

ctdbAttachTable(hTable, datno);


/* read the records */

if (ctdbFirstRecord(hRecord) == CTDBRET_OK)

do

{

count++;

}

while (ctdbNextRecord(hRecord) == CTDBRET_OK);


/* cleanup */

ctdbDetachtable(hTable);

ctdbFreeRecord(hRecord);

ctdbFreeTable(hTable);

ctdbLogout(hSession);

ctdbFreeSession(hSession);

SEE ALSO

ctdbAttachTable(), ctdbAttachTableXtd()

ctdbDisconnect

Disconnect a database.

Declaration

CTDBRET ctdbDisconnect(CTHANDLE Handle)

Description

ctdbDisconnect() disconnects a database from a database handle. Once a database has been disconnected from a database handle, that database is no longer considered "active."

  • Handle [in] the database handle.

Use ctdbConnect() to connect a database to a database handle.

Use ctdbDisconnectAll() to disconnect all databases associated with a Session.

Returns

ctdbDisconnect() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


ctdbDisconnect(hDatabase);

ctdbLogout(hSession);

ctdbFreeDatabase(hDatabase);

ctdbFreeSession(hSession);

See also

ctdbAllocDatabase(), ctdbConnect(), ctdbDisconnectAll(), ctdbCreateDatabase()

 

ctdbDropTable

Drop the table from the database.

Declaration

CTDBRET ctdbDropTable(CTHANDLE Handle, pTEXT TableName)

Description

ctdbDropTable() drops the table from the database, but does not delete the table or index files from disk. When a table is dropped, the allocated records, fields, index and segments are freed from memory.

  • Handle [in] the handle of the database that contains the table to be dropped.
  • TableName [in] the name of the table to be dropped.

Note the different syntax from SQL: A SQL Drop Table operation deletes the files from disk, while this function does not. If you wish to delete the files as well, use the ctdbDeleteTable() function. Use ctdbAddTable() to add a table to a database.

Returns

ctdbDropTable() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


eRet = ctdbConnect(hDatabase, database_name);

eRet = ctdbDropTable(hDatabase, table_name);

See also

ctdbDeleteTable(), ctdbAddTable(), ctdbAllocDatabase()

 

ctdbDelFTI

Delete a table Full-Text Search configuration.

See ctdbDelFTI

 

ctdbDetachSession

Detaches a FairCom DB API session handle from an existing c-tree connection.

DECLARATION

CTDBRET ctdbDECL ctdbDetachSession(CTHANDLE Handle);

DESCRIPTION

ctdbDetachSession() detaches a FairCom DB API session handle. The c-tree ISAM or low-level un-initialization is not called, but the session handle control structures are released and re- initialized. Handle is a session handle allocated by ctdbAllocSesison().

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Appendix A for a complete listing of valid c-tree Plus error values.

EXAMPLE

/* logon to c-tree using ISAM function */

INTISAMX(10, 32, 32, 10, (USERPRF_NTKEY | USERPRF_CLRCHK));


/* attach session to server handle */

if (ctdbAttachSession(hSession, NO) != CTDBRET_OK)

    printf("ctdbAttachSession failed\n");


/*

... do something useful ...

*/


/* detach from session */

if (ctdbDetachSession(hSession) != CTDBRET_OK)

    printf("ctdbDetachSession failed\n");


/* perform an ISAM logout */

CLISAM();

SEE ALSO

ctdbAttachSession()

 

ctdbDisconnectAll

Disconnect all databases.

Declaration

CTDBRET ctdbDisconnectAll(CTHANDLE Handle)

Description

ctdbDisconnectAll() disconnects all connected databases. Once a database has been disconnected from a database handle, that database is no longer considered "active."

  • Handle [in] the session handle.

Use ctdbConnect() to connect a database to a session via a database handle.

Use ctdbDisconnect() to disconnect just one database.

A database created with ctdbCreateDatabase() is automatically connected to the present session.

Returns

ctdbDisconnect() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


ctdbCloseAll(hDatabase);   

ctdbDisconnectAll(hSession);

ctdbLogout(hSession);

ctdbFreeTable(hTable);

ctdbFreeDatabase(hDatabase);

ctdbFreeSession(hSession);

See also

ctdbAllocSession(), ctdbConnect(), ctdbDisconnect(), ctdbCreateDatabase()

 

 

 

 

 

 

ctdbDetachSession

Detaches a FairCom DB API session handle from an existing c-tree connection.

Declaration

CTDBRET ctdbDECL ctdbDetachSession(CTHANDLE Handle);

Description

ctdbDetachSession() detaches a FairCom DB API session handle. The c-tree ISAM or low-level un-initialization is not called, but the session handle control structures are released and re- initialized. Handle is a session handle allocated by ctdbAllocSesison().

Return

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.

See Errors for a complete listing of valid c-tree error values.

Example

/* logon to c-tree using ISAM function */
INTISAMX(10, 32, 32, 10, (USERPRF_NTKEY | USERPRF_CLRCHK));

/* attach session to server handle */
if (ctdbAttachSession(hSession, NO) != CTDBRET_OK)
    printf("ctdbAttachSession failed\n");

/*
... do something useful ...
*/

/* detach from session */
if (ctdbDetachSession(hSession) != CTDBRET_OK)
    printf("ctdbDetachSession failed\n");

/* perform an ISAM logout */
CLISAM();

See Also: 
ctdbAttachSession()

 

ctdbDisconnect

Disconnect a database.

Declaration

CTDBRET ctdbDisconnect(CTHANDLE Handle)

Description

ctdbDisconnect() disconnects a database from a database handle. Once a database has been disconnected from a database handle, that database is no longer considered "active."

  • Handle [in] the database handle.

Use ctdbConnect() to connect a database to a database handle.

Use ctdbDisconnectAll() to disconnect all databases associated with a Session.

Returns

ctdbDisconnect() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example


ctdbDisconnect(hDatabase);
ctdbLogout(hSession);
ctdbFreeDatabase(hDatabase);
ctdbFreeSession(hSession);

See also:
ctdbAllocDatabase(), ctdbConnect(), ctdbDisconnectAll(), ctdbCreateDatabase()

 

ctdbDisconnectAll

Disconnect all databases.

Declaration

CTDBRET ctdbDisconnectAll(CTHANDLE Handle)

Description

ctdbDisconnectAll() disconnects all connected databases. Once a database has been disconnected from a database handle, that database is no longer considered "active."

  • Handle [in] the session handle.

Use ctdbConnect() to connect a database to a session via a database handle.

Use ctdbDisconnect() to disconnect just one database.

A database created with ctdbCreateDatabase() is automatically connected to the present session.

Returns

ctdbDisconnect() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example

ctdbCloseAll(hDatabase);   
ctdbDisconnectAll(hSession);
ctdbLogout(hSession);
ctdbFreeTable(hTable);
ctdbFreeDatabase(hDatabase);
ctdbFreeSession(hSession);

See also:
ctdbAllocSession(), ctdbConnect(), ctdbDisconnect(), ctdbCreateDatabase()

 

ctdbDropDatabase

Drop a database from a session dictionary. The data and index files are not deleted from disk.

Declaration

CTDBRET ctdbDropDatabase(CTHANDLE Handle, cpTEXT Name)

Description

ctdbDropDatabase() drops the database from the session dictionary, but does not delete the database file and index file.

  • Handle [in] - the handle of the session that contains the database to be dropped.
  • Name [in] - the database name.

Use ctdbAddDatabase() to add a database to a session. Use ctdbDeleteDatabase() to drop the database from the session and delete the database file and index file.

Returns

ctdbDropDatabase() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example

eRet = ctdbLogon(hSession, "FAIRCOMS", "ADMIN", "ADMIN");
eRet = ctdbDropDatabase(hSession, database_name);

See also: 
ctdbAllocSession(), ctdbAddDatabase(), ctdbDeleteDatabase()

 

ctdbDuplicateRecord

Return a duplicate copy of a record.

Declaration

CTHANDLE ctdbDuplicateRecord(CTHANDLE Handle)

Description

ctdbDuplicateRecord ()duplicates an existing record.

  • Handle [in] the record handle to be duplicated.

Returns

ctdbDuplicateRecord() returns a copy of the record, or NULL on failure.