Data Types

ctdb_u16TOu8

Converts a UTF-16 string to a UTF-8 encoding.

DECLARATION

NINT ctu16TOu8(pWCHAR u16str, pTEXT u8str, NINT u8size);

DESCRIPTION

ctdb_u16TOu8() converts a UTF-16 encoded string to a UTF-8 Unicode string. The input strings are assumed to be terminated by the nul character. All output buffer sizes are specified in bytes.

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.
153 VBSZ_ERR Output buffer too small.
446 BMOD_ERR Bad key segment mode.

See Appendix "c-tree Plus Error Codes" in the c-tree Plus Programmer's Reference Guide for a complete listing of valid c-tree Plus error values.

EXAMPLE

TEXT buffer[512];

switch (ctdb_u16TOu8(tableName, buffer, sizeof(buffer))

{

    case CTDBRET_OK:

    {

        printf("UTF-16 to UTF-8 conversion ok\n");

        break;

    }

    case VBSZ_ERR:

    {

        printf("Conversion buffer is too small\n");

        break;

    }

    case BMOD_ERR:

    {

        printf("Problem occurred during conversion\n");

        break;

    }

    default:

    {

        printf("Unknown error code\n");

        break;

    }

}

SEE ALSO

ctdb_u8TOu16

ctdb_u8TOu16

Converts an ASCII or UTF-8 encoded string to a UTF-16 string.

DECLARATION

NINT ctdb_u8TOu16(pTEXT u8str, pWCHAR u16str, NINT u16size);

DESCRIPTION

ctdb_u8TOu16() converts an ASCII or UTF-8 encoded string to a UTF-16 Unicode string. The input strings are assumed to be terminated by a NULL character. All output buffer sizes are specified in bytes.

RETURN

Value Symbolic Constant Explanation
0 NO_ERROR No error occurred.
153 VBSZ_ERR Output buffer too small.
446 BMOD_ERR Bad key segment mode.

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

EXAMPLE

WCHAR buffer[256];

switch (ctdb_u8TOu16("tablename", buffer, sizeof(buffer))

{

    case CTDBRET_OK:

    {

        printf("UTF-8 to UTF-16 conversion ok\n");

        break;

    }

    case VBSZ_ERR:

    {

        printf("Conversion buffer is too small\n");

        break;

    }

    case BMOD_ERR:

    {

        printf("Problem occurred during conversion\n");

        break;

    }

    default:

    {

        printf("Unknown error code\n");

        break;

    }

}

SEE ALSO

ctdb_u16TOu8()

 

ctdbBigIntToCurrency

Convert a big integer value to a CTCURRENCY value.

Declaration

CTDBRET ctdbBigIntToCurrency(CTBIGINT value, pCTCURRENCY pCurrency)

Description

ctdbBigIntToCurrency() converts a big integer (8 bytes signed integer) value to a CTCURRENCY (8 bytes signed integer) value. Use ctdbCurrencyToBigInt() to convert from a CTCURRENCY value to a big integer (CTBIGINT) value.

  • value [in] the CTBIGINT value (8 bytes integer).
  • pCurrency [out] the CTCURRENCY value (8 bytes integer).

Returns

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

A possible error associated with ctdbBigIntToCurrency() is CTDBRET_NULARG since a Null argument is not valid in pCurrency.

See also

ctdbCurrencyToBigInt()

 

ctdbBigIntToFloat

Convert a big integer value to a float.

Declaration

CTDBRET ctdbBigIntToFloat(CTBIGINT value, pCTFLOAT pFloat)

Description

ctdbBigIntToFloat() converts a big integer value to a float. A big integer is an 8 bytes integer value. Use ctdbFloatToBigInt() to convert from a float to a big integer. Use ctdbBigIntToLong() to convert a big integer value to a LONG.

  • value [in] the big integer value (8 bytes signed integer).
  • pFloat [out] the float value.

Returns

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

The possible error associated with ctdbBigIntToFloat() is CTDBRET_NULARG since a Null argument is not valid in pFloat.

See also

ctdbFloatToBigInt(), ctdbBigIntToLong()

ctdbBigIntToLong

Convert a big integer value to a LONG.

Declaration

CTDBRET ctdbBigIntToLong(CTBIGINT value, pLONG pLong)

Description

ctdbBigIntToLong() converts a big integer value to a LONG. A big integer is an 8 bytes integer value. Use ctdbLongToBigInt() to convert from a LONG to a big integer.

  • value [in] the big integer value (8 bytes signed integer).
  • pLong [out] the CTSIGNED LONG value (4 bytes signed integer).

Returns

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

Possible errors associated with ctdbBigIntToLong() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pLong
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbLongToBigInt()

ctdbBigIntToNumber

Convert a big integer to a CTNUMBER value.

Declaration

CTDBRET ctdbBigIntToNumber(CTBIGINT value, pCTNUMBER pNumber)

Description

ctdbBigIntToNumber() converts a big integer value to CTNUMBER. Use ctdbNumberToBigInt() to convert from a big integer to CTNUMBER.

  • value [in] the CTBIGINT value.
  • pNumber [out] pointer to CTNUMBER.

Returns

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

The possible error associated with ctdbBigIntToNumber() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pNumber

See also

ctdbNumberToBigInt()

ctdbBigIntToString

Convert a big integer value to a string.

Declaration

CTDBRET ctdbBigIntToString(CTBIGINT value, pTEXT pStr, NINT size)

Description

ctdbBigIntToString() converts a big integer value to a string. A big integer is an 8 bytes integer value. Use ctdbStringToBigInt() to convert from a string to a big integer.

  • value [in] the big integer value (8 bytes signed integer).
  • pStr [out] the string value.
  • size [in] the string size in bytes

Returns

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

The possible error associated with ctdbBigIntToString() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbStringToBigInt()

 

ctdbBlobClear

Clear a blob variable by releasing memory associated with data.

Declaration

CTDBRET ctdbBlobClear(pCTBLOB pBlob)

Description

ctdbBlobClear() clears a blob variable by releasing memory associated with data, setting data to NULL and size to zero.

  • pBlob [in] the blob pointer.

Returns

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

See also

ctdbBlobGetData(), ctdbBlobCmp(), ctdbBlobGetSize(), ctdbBlobSet(), ctdbBlobFree()

ctdbBlobCmp

Compare two blobs.

Declaration

NINT ctdbBlobCmp(pCTBLOB left, pCTBLOB right)

Description

ctdbBlobCmp() compares two blobs.

  • left [in] the first blob pointer.
  • right [in] the second blob pointer

Returns

ctdbBlobCmp() return a negative value if left < right, positive if left > right, and zero if both blobs are equal

See also

ctdbBlobGetData(), ctdbBlobClear(), ctdbBlobGetSize(), ctdbBlobSet()

 

ctdbBlobGetData

Return a pointer to the blob data.

Declaration

pVOID ctdbBlobGetData(pCTBLOB pBlob)

Description

ctdbBlobGetData() retrieves a pointer to the blob data.

  • pBlob [in] the blob pointer.

Returns

ctdbBlobGetData() returns the pointer to the blob data

See also

ctdbBlobGetSize(), ctdbBlobClear(), ctdbBlobCmp(), ctdbBlobSet()

ctdbBlobGetSize

Return the allocated size of a blob.

Declaration

VRLEN ctdbBlobGetSize(pCTBLOB pBlob)

Description

ctdbBlobGetSize() retrieves the allocated size of a blob.

  • pBlob [in] the blob pointer.

Returns

ctdbBlobGetSize() returns the allocated size of a blob

See also

ctdbBlobGetData(), ctdbBlobClear(), ctdbBlobCmp(), ctdbBlobSet()

ctdbBlobSet

Set the blob data.

Declaration

CTDBRET ctdbBlobSet(pCTBLOB pBlob, pVOID buffer, VRLEN size)

Description

ctdbBlobSet() sets the blob data.

  • pBlob [in/out] the blob pointer.
  • buffer [in] the pointer to data.
  • size [in] the number of bytes in the buffer

Returns

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

See also

ctdbBlobGetData(), ctdbBlobCmp(), ctdbBlobGetSize(), ctdbBlobFree()

 

ctdbCurrencyAbs

Return the absolute value of a CTCURRENCY type value.

Declaration

CTCURRENCY ctdbCurrencyAbs(CTCURRENCY left)

Description

ctdbCurrencyAbs() returns the absolute value of a CTCURRENCY type value.

  • left [in] the value to be converted to absolute.

Returns

ctdbCurrencyAbs() returns the absolute value.

See also

ctdbCurrencyAdd(), ctdbCurrencySub(), ctdbCurrencyMul(), ctdbCurrencyDiv(), ctdbCurrencyCmp(), ctdbCurrencyRound()

ctdbCurrencyAdd

Add two currency values. pResult = left + right

Declaration

CTDBRET ctdbCurrencyAdd(CTCURRENCY left, CTCURRENCY right, pCTCURRENCY pResult)

Description

ctdbCurrencyAdd() adds two currency values. pResult = left + right. Do not make regular additions with CTCURRENCY values.

  • left [in] the first value to be added.
  • right [in] the second value to be added.
  • pResult [out] the result of the add operation.

Returns

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

The possible errors associated with ctdbCurrencyAdd() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_UNDERFLOW (4039): Operation caused underflow
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbCurrencySub(), ctdbCurrencyMul(), ctdbCurrencyDiv()

ctdbCurrencyCmp

Compare two CTCURRENCY type values.

Declaration

NINT ctdbCurrencyCmp(CTCURRENCY left, CTCURRENCY right)

Description

ctdbCurrencyCmp() compares two CTCURRENCY values.

  • left [in] the first value to be compared.
  • right [in] the second value to be compared.

Returns

ctdbCurrencyCmp() returns a negative value if left < right, positive value if left > right, and zero if left == right

See also

ctdbCurrencyAdd(), ctdbCurrencySub(), ctdbCurrencyMul(), ctdbCurrencyDiv(), ctdbCurrencyAbs(), ctdbCurrencyRound()

ctdbCurrencyDiv

Divide a currency value by another currency value. pResult = left / right.

Declaration

CTDBRET ctdbCurrencyDiv(CTCURRENCY left, CTCURRENCY right,

                        pCTCURRENCY pResult)

Description

ctdbCurrencyDiv() divides the left currency value by the right currency value (e.g., pResult = left / right). Do not make regular division with CTCURRENCY values. Use regular division between a CTCURRENCY value and a numeric value (int, COUNT, FLOAT, etc.).

  • left [in] the value to be divided (divisor).
  • right [in] the value to divide (dividend).
  • pResult [out] the result of the Div operation.

Returns

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

The possible errors associated with ctdbCurrencyDiv() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_DIVBYZERO (4040): Division by zero error

See also

ctdbCurrencyAdd(), ctdbCurrencySub(), ctdbCurrencyMul()

ctdbCurrencyMul

Multiply two CTCURRENCY values.

Declaration

CTDBRET ctdbCurrencyMul(CTCURRENCY left, CTCURRENCY right,

                        pCTCURRENCY pResult)

Description

ctdbCurrencyMul() multiplies two currency values. pResult = left * right. Do not use regular multiplication with CTCURRENCY values. Use regular multiplication with a combination of a CTCURRENCY value and a numeric value (int, COUNT, FLOAT, etc.).

  • left [in] the first value to be multiplied.
  • right [in] the second value to be multiplied.
  • pResult [out] the result of the multiplication operation.

Returns

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

The possible errors associated with ctdbCurrencyMul() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbCurrencyAdd(), ctdbCurrencySub(), ctdbCurrencyDiv()

ctdbCurrencyRound

Round a currency value to a given number of decimal places.

Declaration

CTDBRET ctdbCurrencyRound(pCTCURRENCY value, NINT scale)

Description

ctdbCurrencyRound() rounds a currency value to a given number of decimal places.

  • value [in/out] the value to be converted to absolute.
  • scale [in] the number of decimal digits.

Returns

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

The possible error associated with ctdbCurrencyMu()l is:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand

See also

ctdbCurrencyAdd(), ctdbCurrencySub(), ctdbCurrencyMul(), ctdbCurrencyDiv(), ctdbCurrencyCmp(), ctdbCurrencyAbs()

ctdbCurrencySub

Subtract two currency values. pResult = left - right.

Declaration

CTDBRET ctdbCurrencySub(CTCURRENCY left, CTCURRENCY right,

                        pCTCURRENCY pResult)

Description

ctdbCurrencySub() subtracts two currency values. pResult = left - right. Do not make regular subtractions with CTCURRENCY values.

  • left [in] the first value, to be subtracted by right.
  • right [in] the second value, to subtract from left.
  • pResult [out] the result of the subtraction operation.

Returns

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

The possible errors associated with ctdbCurrencySub() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_UNDERFLOW (4039): Operation caused underflow
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbCurrencyAdd(), ctdbCurrencyMul(), ctdbCurrencyDiv()

ctdbCurrencyToBigInt

Convert a CTCURRENCY value to a big integer value.

Declaration

CTDBRET ctdbCurrencyToBigInt(CTCURRENCY currency, pCTBIGIND pValue)

Description

ctdbCurrencyToBigInt() converts a CTCURRENCY (8 bytes signed integer) value to a big integer (8 bytes signed integer) value. Use ctdbBigIntToCurrency() to convert from a big integer (CTBIGINT) value to a CTCURRENCY value. Use ctdbCurrencyToLong() to convert from CTCURRENCY to a CTSIGNED (4 bytes signed integer).

  • currency [in] the CTCURRENCY value (8 bytes integer).
  • pValue [out] the CTBIGINT value (8 bytes integer).

Returns

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

The possible error associated with ctdbCurrencyToBigInt() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbBigIntToCurrency()

ctdbCurrencyToFloat

Convert a CTCURRENCY value to a float value.

Declaration

CTDBRET ctdbCurrencyToFloat(CTCURRENCY currency, pCTFLOAT pValue)

Description

ctdbCurrencyToFloat() converts a CTCURRENCY (8 bytes signed integer) value to a float value. Use ctdbFloatToCurrency() to convert from a float to a CTCURRENCY value.

  • currency [in] the CTCURRENCY value (8 bytes integer).
  • pValue [out] the CTFLOAT value.

Returns

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

The possible error associated with ctdbCurrencyToFloat() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbFloatToCurrency()

ctdbCurrencyToLong

Convert a CTCURRENCY value to a LONG value.

Declaration

CTDBRET ctdbCurrencyToLong(CTCURRENCY currency, pCTSIGNED pValue)

Description

ctdbCurrencyToLong() converts a CTCURRENCY (8 bytes signed integer) value to a CTSGINED (4 bytes signed integer) value. Use ctdbLongToCurrency() to convert from a LONG value to a CTCURRENCY value.

  • currency [in] the CTCURRENCY value (8 bytes integer).
  • pValue [out] the CTSIGNED value (4 bytes integer).

Returns

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

The possible error associated with ctdbCurrencyToLong() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbLongToCurrency()

ctdbCurrencyToMoney

Convert a CTCURRENCY value to a CTMONEY value.

Declaration

CTDBRET ctdbCurrencyMoney(CTCURRENCY currency, pCTMONEY pMoney)

Description

ctdbCurrencyToMoney() converts a CTCURRENCY value to a CTMONEY value. A currency value is an 8 bytes integer. Use ctdbMoneyToCurrency() to convert from a CTMONEY value to a CTCURRENCY value.

  • currency [in] the CTCURRENCY value (8 bytes integer).
  • pMoney [out] the CTMONEY value.

Returns

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

The possible error associated with ctdbCurrencyToMoney() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pMoney
  • CTDBRET_OVERFLOW (4038): Operation caused overflow
  • CTDVRET_UNDERFLOW (4039): Operation caused underflow

See also

ctdbMoneyToCurrency()

ctdbCurrencyToNumber

Convert a CTCURRENCY value to a CTNUMBER value.

Declaration

CTDBRET ctdbCurrencyToNumber(CTCURRENCY value, pCTNUMBER pNumber)

Description

ctdbCurrencyToNumber() converts a CTCURRENCY value to a CTNUMBER value. Use ctdbNumberToCurrency() to convert from a CTNUMBER to CTCURRENCY.

  • value [in] the CTCURRENCY value.
  • pNumber [out] pointer to CTNUMBER.

Returns

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

The possible error associated with ctdbCurrencyToNumber() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pNumber

See also

ctdbNumberToCurrency(), ctdbNumberToLong()

ctdbCurrencyToString

Convert a CTCURRENCY value to a string value.

Declaration

CTDBRET ctdbCurrencyToString(CTCURRENCY currency, pTEXT pStr, VRLEN size)

Description

ctdbCurrencyToString() converts a CTCURRENCY (8 bytes signed integer) value to a string value. Use ctdbStringToCurrency() to convert from a string to a CTCURRENCY value.

  • currency [in] the CTCURRENCY value (8 bytes integer).
  • pStr [out] the string value.
  • size [in] the string size in bytes.

Returns

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

The possible error associated with ctdbCurrencyToString() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbStringToCurrency()

 

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

ctdbFloatToBigInt

Convert a float to a big integer value.

Declaration

CTDBRET ctdbFloatToBigInt(CTFLOAT value, pCTBIGINT pBigInt)

Description

ctdbFloatToBigInt() converts a float to a big integer value. A big integer is an 8 bytes integer value. Use ctdbBigIntToFloat() to convert from a big integer to a float.

  • value [in] the float value.
  • pBigInt [out] the big integer value (8 bytes signed integer).

Returns

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

The possible error associated with ctdbFloatToBigInt() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbBigIntToFloat()

ctdbFloatToCurrency

Convert a float value to a CTCURRENCY value.

Declaration

CTDBRET ctdbFloatToCurrency(CTFLOAT value, pCTCURRENCY pCurrency)

Description

ctdbFloatToCurrency() converts a floating point value to a CTCURRENCY (8 bytes signed integer) value. Use ctdbCurrencyToFloat() to convert from a float to a CTCURRENCY value.

  • value [in] the CTFLOAT value.
  • pCurrency [out] the CTCURRENCY value (8 bytes integer).

Returns

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

The possible error associated with ctdbFloatToCurrency() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbCurrencyToFloat()

ctdbFloatToMoney

Converts a floating point value to a CTMONEY type

Declaration

CTDBRET ctdbFloatToMoney(CTFLOAT value, pCTMONEY pMoney)

Description

ctdbFloatToMoney() converts from a floating point number to CTMONEY. Use ctdbMoneyToFloat() to convert a CTMONEY value to a floating point number.

  • value [in] the floating point value to convert.
  • pMoney [out] the pointer to the CTMONEY value.

Returns

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

The possible errors associated with ctdbFloatToMoney() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbMoneyToFloat()

ctdbFloatToNumber

Convert a float to a CTNUMBER value.

Declaration

CTDBRET ctdbFloatToNumber(CTFLOAT value, pCTNUMBER pNumber)

Description

ctdbFloatToNumber() converts a floating point value to a CTNUMBER value. Use ctdbNumberToFloat() to convert a CTNUMBER to float.

  • value [in] the float value.
  • pNumber [out] pointer to CTNUMBER.

Returns

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

The possible error associated with ctdbFloatToNumber() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pNumber

See also

ctdbNumberToFloat()

ctdbGetDay

Retrieve the day of the month from a packed CTDATE.

Declaration

NINT ctdbGetDay(CTDATE date)

Description

ctdbGetDay() retrieves the day of the month from as packed CTDATE. To retrieve the month from a packed CTDATE, use ctdbGetMonth(). To retrieve the year from a packed CTDATE, use ctdbGetYear(). To retrieve the day of the week from a packed CTDATE, use ctdbDayOfWeek().

  • date is the date in CTDATE format.

Returns

ctdbGetDay() returns the day of the month on success or 0 on error.

See also

ctdbGetMonth(), ctdbGetYear(), ctdbDayOfWeek()

 

ctdbGetDefDateType

Retrieve the default date type.

Declaration

CTDATE_TYPE ctdbGetDefDateType(CTHANDLE Handle)

Description

ctdbGetDefDateType() retrieves the default date type for the present session. Use ctdbSetDefDateType() to define the default date type. Initially, the default is CTDATE_MDCY, indicating month, day, century, year (4 digits for the year). The possible date types are given in FairCom DB API definitions.

  • Handle [in] any FairCom DB API Handle.

Returns

ctdbGetDefDateType() returns the default date type, or 0 on error.

ctdbGetDefFloatFormat

Retrieve the default floating point format string

Declaration

cpTEXT ctdbDECL ctdbGetDefFloatFormat(CTHANDLE Handle)

Description

ctdbGetDefFloatFormat() retrieves the default floating point format string.

  • Handle [in] any FairCom DB API Handle.

Returns

ctdbGetDefFloatFormat() returns the string format to be used by sprintf() or sscanf().

ctdbGetDefTimeType

Retrieve the default time type.

Declaration

CTTIME_TYPE ctdbGetDefTimeType(CTHANDLE Handle)

Description

ctdbGetDefTimeType() retrieves the default time type for the present session. Initially, the default is CTTIME_HMP, indicating hour, minute and am/pm. The possible time types are given in FairCom DB API definitions. Use ctdbSetDefTimeType() to define the default time type.

  • Handle [in] any FairCom DB API Handle.

Returns

ctdbGetDefTimeType() returns the default time type, or 0 on error.

 

ctdbGetFieldAsUTF16

Retrieves the field data as a Unicode UTF-16 string.

Declaration

CTDBRET ctdbGetFieldAsUTF16(CTHANDLE Handle, NINT FieldNbr, pWCHAR pValue, VRLEN size);

Description

ctdGetFieldAsUTF16() retrieves the field data as a Unicode UTF-16 string. If the underlying field type is not one of the Unicode field types, the data is converted to UTF-16 strings. Handle is a record handle, FieldNbr is the number of the field, pValue is a pointer to a wide (UTF-16) string buffer and size indicates the size in bytes of the string area.

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

CTDBRET CheckData(CTHANDLE hRecord, pTEXT str, NINT val)

{

CTDBRET eRet;

WCHAR WStr[32];

TEXT s[64];

CTSIGNED t;


if ((eRet = ctdbGetFieldAsUTF16(hRecord, 0, WStr, sizeof(WStr))) != CTDBRET_OK)

{

printf("ctdbGetFieldAsUTF16 failed with error %d", eRet);

goto Exit;

}

if ((eRet = (CTDBRET)ctdb_u16TOu8(WStr, s, sizeof(s))) != CTDBRET_OK)

{

printf("ctdb_u16TOu8 failed with error %d", eRet);

goto Exit;

}

if (strcmp(s, str) != 0)

{

printf("UNICODE field contents not the same written");

eRet = CTDBRET_DIFFERENT;

goto Exit;

}

if ((eRet = ctdbGetFieldAsSigned(hRecord, 1, &t)) != CTDBRET_OK)

{

printf("ctdbGetFieldAsSigned failed with error %d", eRet);

goto Exit;

}

if ((NINT)t != val)

{

printf("integer field contents not the same written");

eRet = CTDBRET_DIFFERENT;

goto Exit;

}

 

Exit:

return eRet;

}

See Also

ctdbSetFieldAsUTF16()

 

ctdbGetFieldDefaultDateType

Retrieves the default value date type.

Declaration

CTDATE_TYPE ctdbGetFieldDefaultDateType(CTHANDLE Handle);

Description

Retrieves the default value date type used when converting strings to dates. Handle must be a FairCom DB API field handle.

Return

Value

Symbolic Constant

Explanation

1

CTDATE_MDCY

Date format is mm/dd/ccyy

2

CTDATE_MDY

Date format is mm/dd/yy

3

CTDATE_DMCY

Date format is dd/mm/ccyy

4

CTDATE_DMY

Date format is dd/mm/yy

5

CTDATE_CYMD

Date format is ccyymmdd

6

CTDATE_YMD

Date format is yymmdd

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

Example

/* check the default date type */

hField = ctdbGetField(hTable, 5);

if (ctdbGetFieldDefaultDateType(hField) != CTDATE_MDCY)

printf("Default date type is not OK\n");

See also

ctdbSetFieldDefaultValue(), ctdbGetFieldDefaultValue(), ctdbClearFieldDefaultValue(), ctdbIsFieldDefaultValueSet(), ctdbClearAllFieldDefaultValue(), ctdbSetFieldDefaultDateTimeType(), ctdbGetFieldDefaultTimeType()

ctdbGetFieldDefaultTimeType

Retrieves the default value time type.

Declaration

CTTIME_TYPE ctdbGetFieldDefaultTimeType(CTHANDLE Handle);

Description

Retrieves the default value time type used when converting strings to dates. Handle must be a FairCom DB API field handle.

Return

Value

Symbolic Constant

Explanation

1

CTTIME_HMSP

Time format is hh:mm:ss am|pm

2

CTTIME_HMP

Time format is hh:mm am|pm

3

CTTIME_HMS

Time format is hh:mm:ss (24 hour)

4

CTTIME_HM

Time format is hh:mm (24 hour)

5

CTTIME_MIL

Time format is hhmm (military)

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

Example

/* check the default time type */

hField = ctdbGetField(hTable, 5);

if (ctdbGetFieldDefaultTimeType(hField) != CTDBRET_OK)

printf("Default time type is not OK\n");

See Also

ctdbSetFieldDefaultValue(), ctdbGetFieldDefaultValue(), ctdbClearFieldDefaultValue(), ctdbIsFieldDefaultValueSet(), ctdbClearAllFieldDefaultValue(), ctdbSetFieldDefaultDateTimeType(), ctdbGetFieldDefaultTimeType()

 

ctdbGetHour

Get the hour from a packed CTTIME.

Declaration

NINT ctdbGetHour(CTTIME Time)

Description

ctdbGetHour() gets the hour from a packed CTTIME.

  • Time is the packed time in CTTIME format.

Returns

ctdbGetHour() returns the hour on success, or -1 on error.

See also

ctdbGetMinute(), ctdbGetSecond()

 

ctdbGetMinute

Get the minute from a packed CTTIME.

Declaration

NINT ctdbGetMinute(CTTIME Time)

Description

ctdbGetMinute() gets the minute from a packed CTTIME.

  • Time is the packed time in CTTIME format.

Returns

ctdbGetMinute() returns the minute, on success or -1 on error.

See also

ctdbGetHour(), ctdbGetSecond()

ctdbGetMonth

Retrieve the month of the year from a packed CTDATE.

Declaration

NINT ctdbGetMonth(CTDATE date)

Description

ctdbGetMonth() retrieves the month of the year from a packed CTDATE. To retrieve the day of the month from a packed CTDATE, use ctdbGetDay(). To retrieve the year from a packed CTDATE, use ctdbGetYear().

  • date is the date in CTDATE format.

Returns

ctdbGetMonth() returns the month of the year on success or 0 on error.

See also

ctdbGetDay(), ctdbGetYear()

 

ctdbGetSecond

Get the whole seconds from a packed CTTIME.

Declaration

NINT ctdbGetSecond(CTTIME Time)

Description

ctdbGetSecond() gets the second from a packed CTTIME.

  • Time is the packed time in CTTIME format.

Returns

ctdbGetSecond() returns the minute, on success or -1 on error.

See also

ctdbGetMinute(), ctdbGetHour()

 

ctdbGetYear

Retrieve the year from a packed CTDATE.

Declaration

NINT ctdbGetYear(CTDATE date)

Description

ctdbGetYear() retrieves the year from a packed CTDATE. To retrieve the day of the month from a packed CTDATE, use ctdbGetDay(). To retrieve the month of the year from a packed CTDATE, use ctdbGetMonth().

  • date is the date in CTDATE format.

Returns

ctdbGetYear() returns the day of the month on success or 0 on error.

See also

ctdbGetMonth(), ctdbGetDay()

 

ctdbIsLeapYear

Indicate if the year in a packed CTDATE is a leap year.

Declaration

CTBOOL ctdbIsLeapYear(CTDATE date)

Description

ctdbIsLeapYear() indicates if the year in a packed CTDATE is a leap year.

  • date is the date in CTDATE format.

Returns

ctdbIsLeapYear() returns YES if the year in a packed CTDATE is a leap year, and NO otherwise.

 

ctdbIsNumberZero

Check if a number is zero.

Declaration

CTBOOL ctdbIsNumberZero(pCTNUMBER pNumber)

Description

ctdbIsNumberZero() checks to see if a number is zero.

  • pNumber [in] pointer to a number.

Returns

ctdbIsNumberZero() returns YES if the number is zero, NO otherwise.

See also

ctdbNumberZero()

 

ctdbLongToBigInt

Convert a LONG value to a big integer.

Declaration

CTDBRET ctdbLongToBigInt(LONG value, pCTBIGINT pBigInt)

Description

ctdbLongToBigInt() converts a LONG value to a big integer value. A big integer is an 8 bytes integer value. Use ctdbBigIntToLong() to convert from a big integer to a LONG.

  • value [in] the CTSIGNED LONG value (4 bytes signed integer).
  • pBigInt [out] the big integer value (8 bytes signed integer).

Returns

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

The possible error associated with ctdbLongToBigInt() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbBigIntToLong()

ctdbLongToCurrency

Convert a LONG value to a CTCURRENCY value.

Declaration

CTDBRET ctdbLongToCurrency(CTSIGNED value, pCTCURRENCY pCurrency)

Description

ctdbLongToCurrency() converts a CTSIGNED (4 bytes signed integer) value to a CTCURRENCY (8 bytes signed integer) value. Use ctdbCurrencyToLong() to convert from a CTCURRENCY value to a LONG value.

  • value [in] the CTSIGNED value (4 bytes integer).
  • pCurrency [out] the CTCURRENCY value (8 bytes integer).

Returns

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

The possible error associated with ctdbLongToCurrency() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbCurrencyToLong()

ctdbLongToMoney

Convert a LONG value to a CTMONEY.

Declaration

CTDBRET ctdbLongToMoney(CTSIGNED value, pCTMONEY pMoney)

Description

ctdbLongToMoney() converts a LONG value to a CTMONEY value. The long value is multiplied by 100 before the conversion. Use ctdbMoneyToLong() to convert from a LONG to CTMONEY.

  • value [in] the CTSIGNED LONG value.
  • pMoney [out] the CTMONEY value.

Returns

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

The possible error associated with ctdbLongToMoney() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbMoneyToLong()

ctdbLongToNumber

Convert a LONG to a CTNUMBER value.

Declaration

CTDBRET ctdbLongToNumber(LONG value, pCTNUMBER pNumber)

Description

ctdbLongToNumber() converts a LONG to a CTNUMBER value. Use ctdbNumberToLong() to convert from CTNUMBER to a LONG.

  • value [in] the LONG value.
  • pNumber [out] pointer to CTNUMBER.

Returns

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

The possible error associated with ctdbLongToNumber() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbNumberToLong()

 

ctdbMoneyAbs

Return the absolute value of a CTMONEY type value.

Declaration

CTMONEY ctdbMoneyAbs(CTMONEY left)

Description

ctdbMoneyAbs() returns the absolute value of a CTMONEY type value.

  • left [in] the value to be converted to absolute.

Returns

ctdbMoneyAbs() returns the absolute value.

See also

ctdbMoneyAdd(), ctdbMoneySub(), ctdbMoneyMul(), ctdbMoneyDiv(), ctdbMoneyCmp()

ctdbMoneyAdd

Add two money values. pResult = left + right

Declaration

CTDBRET ctdbMoneyAdd(CTMONEY left, CTMONEY right, pCTMONEY pResult)

Description

ctdbMoneyAdd() add two money values. pResult = left + right. Do not make regular additions with CTMONEY values.

  • left [in] the first value to be added.
  • right [in] the second value to be added.
  • pResult [out] the result of the add operation.

Returns

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

The possible errors associated with ctdbMoneyAdd() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_UNDERFLOW (4039): Operation caused underflow
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbMoneySub(), ctdbMoneyMul(), ctdbMoneyDiv()

ctdbMoneyCmp

Compare two CTMONEY type values.

Declaration

NINT ctdbMoneyCmp(CTMONEY left, CTMONEY right)

Description

ctdbMoneyCmp() compares two CTMONEY values.

  • left [in] the first value to be compared.
  • right [in] the second value to be compared.

Returns

ctdbMoneyCmp() returns a negative value if left < right, positive value if left > right, and zero if left == right

See also

ctdbMoneyAdd(), ctdbMoneySub(), ctdbMoneyMul(), ctdbMoneyDiv(), ctdbMoneyAbs()

ctdbMoneyDiv

Divide one money value by another money value. pResult = left / right.

Declaration

CTDBRET ctdbMoneyDiv(CTMONEY left, CTMONEY right, pCTMONEY pResult)

Description

ctdbMoneyDiv() divide one money value by another money value. pResult = left / right. Do not make regular division with CTMONEY values. You may user regular division between a CTMONEY value and a numeric value (int, COUNT, FLOAT, etc.).

  • left [in] the value to be divided (divisor).
  • right [in] the value to divide (dividend).
  • pResult [out] the result of the Div operation.

Returns

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

The possible errors associated with ctdbMoneyDiv() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_DIVBYZERO (4040): Division by zero error

See also

ctdbMoneyAdd(), ctdbMoneySub(), ctdbMoneyMul()

ctdbMoneyMul

Multiply two CTMONEY values.

Declaration

CTDBRET ctdbMoneyMul(CTMONEY left, CTMONEY right, pCTMONEY pResult)

Description

ctdbMoneyMul() multiplies two money values. pResult = left * right. Do not make regular multiplication with CTMONEY values. It is possible to use regular multiplication with a CTMONEY value and a numeric value (int, COUNT, FLOAT, etc.).

  • left [in] the first value to be multiplied.
  • right [in] the second value to be multiplied.
  • pResult [out] the result of the multiplication operation.

Returns

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

The possible errors associated with ctdbMoneyMul() are:

  • CTDBRET_NULARG (4070): Null argument not valid in any operand
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbMoneyAdd(), ctdbMoneySub(), ctdbMoneyDiv()

ctdbMoneySub

Subtract two money values. pResult = left - right.

Declaration

CTDBRET ctdbMoneySub(CTMONEY left, CTMONEY right, pCTMONEY pResult)

Description

ctdbMoneySub() subtracts two money values. pResult = left - right. Do not make regular subtractions with CTMONEY values.

  • left [in] the first value, to be subtracted by right.
  • right [in] the second value, to subtract from left.
  • pResult [out] the result of the subtraction operation.

Returns

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

The possible errors associated with ctdbMoneySub() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_UNDERFLOW (4039): Operation caused underflow
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbMoneyAdd(), ctdbMoneyMul(), ctdbMoneyDiv()

ctdbMoneyToCurrency

Convert a CTMONEY value to a CTCURRENCY value.

Declaration

CTDBRET ctdbMoneyToCurrency(CTMONEY money, pCTCURRENCY pCurrency)

Description

ctdbMoneyToCurrency() converts a CTMONEY value to a CTCURRENCY value. A currency value is an 8 bytes integer. Use ctdbCurrencyToMoney() to convert from a CTCURRENCY value to a CTMONEY value.

  • money [in] the CTMONEY value.
  • pCurrency [out] the CTCURRENCY value (8 bytes integer).

Returns

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

The possible error associated with ctdbMoneyToCurrency() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbCurrencyToMoney()

ctdbMoneyToFloat

Convert a CTMONEY value to a floating point number

Declaration

CTDBRET ctdbMoneyToFloat(CTMONEY money, pCTFLOAT pValue)

Description

ctdbMoneyToFloat() converts a CTMONEY value to a floating point number. Use ctdbFloatToMoney() to convert from a floating point number to CTMONEY.

  • money [in] the CTMONEY type value.
  • pValue [out] the floating point value.

Returns

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

The possible error associated with ctdbMoneyToFloat() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbFloatToMoney()

ctdbMoneyToLong

Convert a CTMONEY value to a LONG.

Declaration

CTDBRET ctdbMoneyToLong(CTMONEY money, pLONG pValue)

Description

ctdbMoneyToLong() converts a CTMONEY value to a LONG. The Fraction part of CTMONEY is discarded and only the integer part is assigned. Use ctdbLongToMoney() to convert from a LONG to CTMONEY.

  • money [in] the CTMONEY value.
  • pValue [out] the LONG value representing the integer part of the monetary value.

Returns

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

The possible error associated with ctdbMoneyToLong() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbLongToMoney()

ctdbMoneyToNumber

Convert a CTMONEY value to a CTNUMBER.

Declaration

CTDBRET ctdbMoneyToNumber(CTMONEY money, pCTNUMBER pNumber)

Description

ctdbMoneyToNumber() converts a CTMONEY value to a CTNUMBER. Use ctdbNumberToMoney() to convert from a CTNUMBER to CTMONEY.

  • money [in] the CTMONEY value.
  • pNumber[out] pointer to CTNUMBER.

Returns

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

The possible error associated with ctdbMoneyToLong() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbNumberToMoney()

ctdbMoneyToString

Convert a CTMONEY type value to a string.

Declaration

CTDBRET ctdbMoneyToString(CTMONEY money, pTEXT pStr, VRLEN size)

Description

ctdbMoneyToString() converts a CTMONEY value to a string. Use ctdbStringToMoney() to convert from a string to CTMONEY.

  • money [in] the CTMONEY value.
  • pStr [out] the pointer to the string that will result from the conversion.
  • size [in] the buffer size of the string.

Returns

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

The possible errors associated with ctdbMoneyToString() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_ARGSMALL (4006): Argument is too small - increase size

See also

ctdbStringToMoney()

 

ctdbNumberAbs

Return the absolute value of a CTNUMBER type value.

Declaration

CTDBRET ctdbNumberAbs(pCTNUMBER pSource, pCTNUMBER pResult)

Description

ctdbNumberAbs() returns the absolute value of a CTNUMBER type value.

  • pSource [in] the value to be converted to absolute.
  • pResult [out] the absolute value.

Returns

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

The possible errors associated with ctdbNumberAbs() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberCmp(), ctdbNumberNegate(), ctdbNumberZero(), ctdbNumberRound(), ctdbNumberCopy(), ctdbNumberGetDecimal()

ctdbNumberAdd

Add two Number values. pResult = left + right

Declaration

CTDBRET ctdbNumberAdd(pCTNUMBER pLeft, pCTNUMBER pRight,

pCTNUMBER pResult)

Description

ctdbNumberAdd() add number pLeft to pRight and store the result in ‘pResult’. Do not make regular additions with CTNUMBER values.

  • pLeft [in] pointer to the first value to be added.
  • pRight [in] pointer to the second value to be added.
  • pResult [out] pointer to the result of the add operation.

Returns

ctdbNumberAdd() returns CTDBRET_OK on success, or FairCom DB API error on failure. The possible error associated with ctdbNumberAdd() is:

  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv()

ctdbNumberCmp

Compare two CTNUMBER type values.

Declaration

NINT ctdbNumberCmp(pCTNUMBER num1, pCTNUMBER num2)

Description

ctdbNumberCmp() compares two CTNUMBER values.

  • num1 [IN], num2 [IN] pointers to the values to be compared.

Returns

ctdbNumberCmp() returns a negative value if num1 < num2, positive value if num1 > num2, and zero if num1 == num2

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberAbs(), ctdbNumberNegate(), ctdbNumberZero(), ctdbNumberRound(), ctdbNumberCopy(), ctdbNumberGetDecimal()

ctdbNumberCopy

Copy a number from pSource to pDest.

Declaration

CTDBRET ctdbNumberCopy(pCTNUMBER pDest, pCTNUMBER pSource)

Description

ctdbNumberAbs() copies a number from pSource to pDest.

  • pDest [out] pointer to the destination of the copy operation.
  • pSource [in] pointer to the source value to be copied.

Returns

ctdbNumberAbs() returns CTDBRET_OK on success, or FairCom DB API error on failure. The possible errors associated with ctdbNumberAbs() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberCmp(), ctdbNumberNegate(), ctdbNumberZero(), ctdbNumberRound(), ctdbNumberCopy(), ctdbNumberGetDecimal()

ctdbNumberDiv

Divide one Number value by another Number value. pResult = pLeft / pRight.

Declaration

CTDBRET ctdbNumberDiv(pCTNUMBER pLeft, pCTNUMBER pRight,

pCTNUMBER pResult)

Description

ctdbNumberDiv() divide one Number value by another Number value. pResult = pLeft / pRight. Do not make regular division with CTNUMBER values.

  • pLeft [in] the value to be divided by pRight (divisor).
  • pRight [in] the value to divide into pLeft (dividend).
  • pResult [out] the result of the Div operation.

Returns

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

The possible errors associated with ctdbNumberDiv() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_DIVBYZERO (4040): Division by zero error

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul()

ctdbNumberGetDecimal

Retrieve the number of digits before and after the decimal point.

Declaration

CTDBRET ctdbNumberGetDecimal(pCTNUMBER data, pNINT digit_before,

pNINT digit_after)

Description

ctdbNumberGetDecimal() retrieves the number of digits before and after the decimal point.

  • data [in] pointer to number.
  • digit_before [out] the number of digits before the decimal place.
  • digit_after [out] the number of digits after the decimal place.

Returns

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

The possible errors associated with ctdbNumberGetDecimal() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_INVNUMBER (4060): Number value invalid (out of bounds)

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberAbs(), ctdbNumberCmp(), ctdbNumberZero(), ctdbNumberCopy(), ctdbNumberGetDecimal(), ctdbNumberCopy(), ctdbNumberRound()

ctdbNumberMul

Multiply two CTNUMBER values.

Declaration

CTDBRET ctdbNumberMul(pCTNUMBER pLeft, pCTNUMBER pRight,

pCTNUMBER pResult)

Description

ctdbNumberMul multiplies two Number values. pResult = pLeft * pRight. Do not use regular multiplication with CTNUMBER values.

  • pLeft [in] the first value to be multiplied.
  • pRight [in] the second value to be multiplied.
  • pResult [out] the result of the multiplication operation.

Returns

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

The possible errors associated with ctdbNumberMul() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberDiv()

ctdbNumberNegate

Negate a number.

Declaration

CTDBRET ctdbNumberNegate(pCTNUMBER pSource, pCTNUMBER pResult)

Description

ctdbNumberNegate negates a number (eg. -Number).

  • pSource [in] the value to be negated.
  • pResult [out] the negated value (= -pSource).

Returns

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

The possible errors associated with ctdbNumberNegate() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberAbs(), ctdbNumberCmp(), ctdbNumberZero(), ctdbNumberRound(), ctdbNumberCopy(), ctdbNumberGetDecimal()

 

ctdbNumberRound

Round a number to a scale.

Declaration

CTDBRET ctdbNumberRound(pCTNUMBER num, NINT scale)

Description

ctdbNumberRound() rounds a number to a certain number of decimal digits.

  • num [in] pointer to the number to be rounded.
  • scale [out] the number of decimal digits.

Returns

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

The possible errors associated with ctdbNumberRound() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberAdd(), ctdbNumberSub(), ctdbNumberMul(), ctdbNumberDiv(), ctdbNumberAbs(), ctdbNumberCmp(), ctdbNumberZero(), ctdbNumberCopy(), ctdbNumberGetDecimal(), ctdbNumberCopy(), ctdbNumberGetDecimal()

ctdbNumberSub

Subtract two Number values. pResult = pLeft - pRight.

Declaration

CTDBRET ctdbNumberSub(pCTNUMBER pLeft, pCTNUMBER pRight, pCTNUMBER pResult)

Description

ctdbNumberSub() subtracts two Number values. pResult = pLeft - pRight. Do not make regular subtractions with CTNUMBER values.

  • pLeft [in] the first value, from which the pRight value will be subtracted.
  • pRight [in] the second value, which is the value to subtract from pLeft.
  • pResult [out] the result of the subtraction operation.

Returns

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

The possible errors associated with ctdbNumberSub() are:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand
  • CTDBRET_UNDERFLOW (4039): Operation caused underflow
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberAdd(), ctdbNumberMul(), ctdbNumberDiv()

ctdbNumberToBigInt

Convert a CTNUMBER value to a big integer.

Declaration

CTDBRET ctdbNumberToBigInt(pCTNUMBER pNumber, pCTBIGINT pValue)

Description

ctdbNumberToBigInt() converts a CTNUMBER value to a big integer (8 bytes). Use ctdbBigIntToNumber() to convert from a big integer to CTNUMBER. Use ctdbNumberToLong() to convert CTNUMBER to a LONG (4 bytes integer).

  • pNumber [in] pointer to CTNUMBER.
  • pValue [out] pointer the CTBIGINT big integer value.

Returns

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

The possible error associated with ctdbNumberToBigInt() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbBigIntToNumber(), ctdbNumberToLong()

ctdbNumberToCurrency

Convert a CTNUMBER value to a currency value.

Declaration

CTDBRET ctdbNumberToCurrency(pCTNUMBER pNumber, pCTCURRENCY pValue)

Description

ctdbNumberToCurrency() converts a CTNUMBER value to a CTCURRENCY value. Use ctdbCurrencyToNumber() to convert from a CTCURRENCY to CTNUMBER. Use ctdbNumberToMoney() to convert CTNUMBER to a CTMONEY.

  • pNumber [in] pointer to the CTNUMBER to be converted.
  • pValue [out] pointer the output CTCURRENCY value.

Returns

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

The possible error associated with ctdbNumberToCurrency() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbCurrencyToNumber(), ctdbNumberToLong(), ctdbNumberToMoney()

ctdbNumberToFloat

Convert a CTNUMBER value to a floating point value.

Declaration

CTDBRET ctdbNumberToFloat(pCTNUMBER pNumber, pCTFLOAT pValue)

Description

ctdbNumberToFloat() converts a CTNUMBER value to a floating point value. Use ctdbFloatToNumber() to convert from float to CTNUMBER.

  • pNumber [in] pointer to CTNUMBER.
  • pValue [out] pointer to floating point value.

Returns

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

The possible error associated with ctdbNumberToFloat() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbFloatToNumber()

ctdbNumberToLong

Convert a CTNUMBER value to a LONG.

Declaration

CTDBRET ctdbNumberToLong(pCTNUMBER pNumber, pLONG pValue)

Description

ctdbNumberToLong() converts a CTNUMBER value to a LONG. Use ctdbLongToNumber() to convert from LONG to CTNUMBER. Use ctdbNumberToBigInt() to convert a CTNUMBER to a big integer (8 byte integer).

  • pNumber [in] pointer to the CTNUMBER value.
  • pValue [out] pointer to the LONG value.

Returns

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

The possible error associated with ctdbNumberToLong() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbLongToNumber(), ctdbNumberToBigInt()

ctdbNumberToMoney

Convert a CTNUMBER value to CTMONEY.

Declaration

CTDBRET ctdbNumberToMoney(pCTNUMBER pNumber, pCTMONEY pMoney)

Description

ctdbNumberToMoney() converts a CTNUMBER value to a CTMONEY. Use ctdbMoneyToNumber() to convert from CTMONEY to CTNUMBER. Use ctdbNumberToCurrency() to convert CTNUMBER to a CTCURRENCY.

ctdbNumberToString

Convert a CTNUMBER value to a string.

Declaration

CTDBRET ctdbNumberToString(pCTNUMBER pNumber, pTEXT pStr, VRLEN size)

Description

ctdbNumberToString() converts a CTNUMBER value to a string. Use ctdbStringToNumber() to convert from a string to CTNUMBER.

  • pNumber [in] pointer to CTNUMBER value.
  • pStr [out] the pointer to the string that will result from the conversion.
  • size [in] the buffer size (in bytes) of the string.

Returns

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

The possible errors associated with ctdbNumberToString() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbStringToNumber()pNumber [in] pointer to the CTNUMBER value.

  • pMoney [out] pointer to the CTMONEY value.

Returns

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

The possible error associated with ctdbNumberToMoney() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pMoney

See also

ctdbMoneyToNumber(), ctdbNumberToCurrency()

ctdbNumberZero

Set the value of a number to zero.

Declaration

CTDBRET ctdbNumberZero(pCTNUMBER pNumber)

Description

ctdbNumberZero() sets the value of a number to zero.

  • pNumber [in] pointer to a number.

Returns

ctdbNumberZero() returns CTDBRET_OK on success, or FairCom DB API error on failure. Use ctdbIsNumberZero() to check if a number is zero.

The possible error associated with ctdbNumberZero() is:

  • CTDBRET_NULARG (4007): Null argument not valid in any operand

See also

ctdbIsNumberZero(), ctdbNumberAbs(), ctdbNumberCmp(), ctdbNumberNegate(), ctdbNumberRound(), ctdbNumberCopy(), ctdbNumberGetDecimal()

 

ctdbSetDefDateType

Set the default date type.

Declaration

CTDBRET ctdbSetDefDateType(CTHANDLE Handle, CTDATE_TYPE DateType)

Description

ctdbSetDefDateType() sets the default date type for the present session. Initially, the default is CTDATE_MDCY, indicating month, day, century, year (4 digits for the year). The possible date types are given in the Date Type Formats table in Date Types. Use ctdbGetDefDateType() to retrieve the default date type.

  • Handle [in] any FairCom DB API Handle.
  • DateType [in] a valid date type. Valid types are listed in the Date Type Formats table in Date Types.

Returns

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

See also

ctdbGetDefDateType()

ctdbSetDefFloatFormat

Set the default floating point format string

Declaration

CTDBRET ctdbDECL ctdbSetDefFloatFormat(CTHANDLE Handle, cpTEXT format)

Description

ctdbSetDefFloatFormat() sets the default floating point format string.

  • Handle [in] any FairCom DB API Handle.
  • format [in] the string format to be used by sprintf() or sscanf().

Returns

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

See also

ctdbGetDefFloatFormat()

ctdbSetDefTimeType

Set the default time type.

Declaration

CTDBRET ctdbSetDefTimeType(CTHANDLE Handle, CTTIME_TYPE TimeType)

Description

ctdbSetDefTimeType() sets the default time type for the present session. Initially, the default is CTTIME_HMP, indicating hour, minute and am/pm. The possible date types are given in the Time Type Formats table in Time Types. Use ctdbGetDefTimeType() to retrieve the default time type.

  • Handle [in] any FairCom DB API Handle.
  • TimeType [in] a valid time type. Valid types are listed in the Time Type Formats table in Time Types.

Returns

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

See also

ctdbGetDefTimeType()

 

ctdbStringToBigInt

Convert a string to a big integer value.

Declaration

CTDBRET ctdbStringToBigInt(pTEXT pStr, pCTBIGINT pValue)

Description

ctdbStringToBigInt() converts a string to a big integer value. A big integer is an 8 bytes integer value. Use ctdbBigIntToString() to convert from a big integer to a string.

  • pStr [in] the string value.
  • pValue [out] the big integer value (8 bytes signed integer).

Returns

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

The possible error associated with ctdbStringToBigInt() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pValue

See also

ctdbBigIntToString()

ctdbStringToCurrency

Convert a string value to a CTCURRENCY value.

Declaration

CTDBRET ctdbStringToCurrency(pTEXT pStr, pCTCURRENCY pCurrency)

Description

ctdbStringToCurrency() converts a string value to a CTCURRENCY (8 bytes signed integer) value. Use ctdbCurrencyToString() to convert from a CTCURRENCY value to a string.

  • pStr [in] the string value.
  • pCurrency [out] the CTCURRENCY value (8 bytes integer).

Returns

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

The possible error associated with ctdbStringToCurrency() is:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr

See also

ctdbCurrencyToString()

ctdbStringToDate

Convert a date in string format to CTDATE packed format.

Declaration

CTDBRET ctdbStringToDate(pTEXT pStr, CTDATE_TYPE DateType,

pCTDATE pDate)

Description

ctdbStringToDate() converts a date in string format to CTDATE packed format. Use ctdbDateToString() to convert a packed CTDATE into a string.

  • pStr [in] the pointer to the string.
  • DateType [in] the date type. Valid types are listed in FairCom DB API Data Types.
  • pDate [out] the pointer to date that will result from the conversion.

Returns

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

The possible errors associated with ctdbStringToDate() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_NOMEMORY (4001): Not enough memory
  • CTDBRET_INVFORMAT (4028): Invalid format in DateType
  • CTDBRET_INVDATE (4029): Invalid packed CTDATE

See also

ctdbStringToTime(), ctdbDateToString()

ctdbStringToDateTime

Convert a date in string format into a packed CTDATETIME.

Declaration

CTDBRET ctdbStringToDateTime(pTEXT pStr, pCTDATETIME pDateTime,

CTDATE_TYPE DateType, CTTIME_TYPE TimeType)

Description

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

  • pStr [in] a pointer to the string with the date and time value.
  • pDateTime [out] Pointer to a CTDATETIME type value to received the converted string date and time
  • DateType [in] the date type. Valid types are listed FairCom DB API Data Types.
  • TimeType [in] the time type. Valid types are listed in FairCom DB API Data Types.

Returns

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

The possible errors associated with ctdbStringToDateTime() 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

ctdbDateTimeToString(), ctdbStringToTime() (ctdbStringToTime, ctdbStringToTime), ctdbStringToDate()

ctdbStringToMoney

Convert a string value to a CTMONEY type value.

Declaration

CTDBRET ctdbStringToMoney(pTEXT pStr, pCTMONEY pMoney)

Description

ctdbStringToMoney() converts from a string to CTMONEY. Use ctdbMoneyToString() to converts a CTMONEY value to a string.

  • pStr [in] the pointer to the string.
  • pMoney [out] the pointer to a CTMONEY type value.

Returns

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

The possible errors associated with ctdbStringToMoney() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbMoneyToString()

ctdbStringToNumber

Convert a string type value to a CTNUMBER.

Declaration

CTDBRET ctdbStringToNumber(pTEXT pStr, pCTNUMBER pNumber)

Description

ctdbStringToNumber() converts a string to a CTNUMBER . Use ctdbNumberToString() to convert from CTNUMBER to a string.

  • pStr [in] the input string to the conversion.
  • pNumber [out] pointer to CTNUMBER that will result from the conversion.

Returns

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

The possible errors associated with ctdbStringToNumber() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_OVERFLOW (4038): Operation caused overflow

See also

ctdbNumberToString()

ctdbStringToTDateTime

Convert a date and time in a string ot a double containing a delphi TDateTime value.

Declaration

CTDBRET ctdbDECL ctdbStringToTDateTime(cpTEXT pStr, DOUBLE* tdatetime, CTDATE_TYPE DateType, CTTIME_TYPE TimeType)

Description

ctdbStringToTDateTime() converts a date and time in a string to a double containing a delphi TDateTime value.

Parameters:

  • pStr [IN] - string containing the date and time
  • unixtime [OUT] - pointer to a time_t type value to receive the converted string date and time
  • DateType [IN] - one of the date types
  • TimeType [IN] - one of the time types

Return values

Returns CTDBRET_OK on success.

ctdbStringToTime

Convert a time in string format to CTTIME packed format with whole second precision.

NOTE: See ctdbStringToTimeMsec() if you need millisecond precision.

Declaration

CTDBRET ctdbStringToTime(pTEXT pStr, CTTIME_TYPE TimeType,

pCTTIME pTime)

Description

ctdbStringToTime() converts a time in string format to CTTIME packed format. Use ctdbTimeToString() to convert a packed CTTIME into a string.

  • pStr [in] the pointer to the string.
  • TimeType [in] the time types. Valid types described in FairCom DB API Data Types.
  • pTime [out] the pointer to a CTTIME value that will result from the conversion.

Returns

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

The possible errors associated with ctdbStringToTime() are:

  • CTDBRET_NULARG (4007): Null argument not valid in pStr
  • CTDBRET_NOMEMORY (4001): Not enough memory
  • CTDBRET_INVFORMAT (4028): Invalid format in TimeType
  • CTDBRET_INVTIME (4033): Invalid packed CTTIME

See also

ctdbTimeToString(), ctdbStringToTimeMsec(), ctdbTimeMsecToString()

ctdbStringToTimeMsec

Convert a time in string format to CTTIMEMS packed format with millisecond precision.

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

Declaration

CTDBRET ctdbDECL ctdbStringToTimeMsec(pTEXT pStr, CTTIME_TYPE TimeType, pCTTIMEMS pTime)

Parameters:

  • pStr [IN] - Time in string format
  • TimeType [IN] - One of the time types
  • pTime [OUT] - Packed time (with milliseconds)

Description

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

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

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

ctdbTimeMsecToString, ctdbStringToTime(), ctdbTimeToString()

ctdbStringToUnixTime

Convert a date and time in a string to a packed CTDATETIME type value

Declaration

CTDBRET ctdbDECL ctdbStringToUnixTime(cpTEXT pStr, time_t* unixtime, CTDATE_TYPE DateType, CTTIME_TYPE TimeType)

Description

ctdbStringToUnixTime() converts a date and time in a string to a packed CTDATETIME type value

 

Parameters:

  • pStr [IN] - String containint the date and time
  • unixtime [OUT] - Pointer to a time_t type value to received the converted string date and time
  • DateType [IN] - One of the date types
  • TimeType [IN] - One of the time types

Return Values

Return CTDBRET_OK on success

 

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