Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for Data Stores Without SQL

SimbaEngine X SDK Documentation > SQL Data Types > SQL Data Types in the C++ SDK

SQL Data Types in the C++ SDK

SqlData objects represent the SQL types and encapsulate the data in a buffer. When you have a SqlData object and would like to know what data type it is representing, you can use GetMetadata()->GetSqlType() to retrieve the associated SQL_[TYPE] type. For more information, see the file SqlData.h.

Fixed Length Types

The structures used to store the fixed-length data types represented by SqlData objects are listed below:

SQL Type SimbaEngine X SDK Data Type

SQL_BIT

simba_uint8

SQL_BIGINT (signed)

simba_int64

SQL_BIGINT (unsigned)

simba_uint64

SQL_DATE

TDWDate

SQL_DECIMAL

TDWExactNumericType

SQL_DOUBLE

simba_double64

SQL_FLOAT

simba_double64

SQL_GUID TDWGuid

SQL_INTEGER (signed)

simba_int32

SQL_INTEGER (unsigned)

simba_uint32

SQL_INTERVAL_DAY

TDWSingleFieldInterval

SQL_INTERVAL_DAY_TO_HOUR

TDWDayHourInterval

SQL_INTERVAL_DAY_TO_MINUTE

TDWDayMinuteInterval

SQL_INTERVAL_DAY_TO_SECOND

TDWDaySecondInterval

SQL_INTERVAL_HOUR

TDWSingleFieldInterval

SQL_INTERVAL_HOUR_TO_MINUTE

TDWHourMinuteInterval

SQL_INTERVAL_HOUR_TO_SECOND

TDWHourSecondInterval

SQL_INTERVAL_MINUTE

TDWSingleFieldInterval

SQL_INTERVAL_MINUTE_SECOND

TDWMinuteSecondInterval

SQL_INTERVAL_MONTH

TDWSingleFieldInterval

SQL_INTERVAL_SECOND

TDWSecondInterval

SQL_INTERVAL_YEAR

TDWSingleFieldInterval

SQL_INTERVAL_YEAR_TO_MONTH

TDWYearMonthInterval

SQL_NUMERIC

TDWExactNumericType

SQL_REAL

simba_double32

SQL_SMALLINT (signed)

simba_int16

SQL_SMALLINT (unsigned)

simba_uint16

SQL_TIME

TDWTime

SQL_TIMESTAMP

TDWTimestamp

SQL_TINYINT (signed)

simba_int8

SQL_TINYINT (unsigned)

simba_uint8

SQL_TYPE_DATE

TDWDate

SQL_TYPE_TIME

TDWTime

SQL_TYPE_TIMESTAMP

TDWTimestamp

SQL_TYPE_DATE

TDWDate

SQL_TYPE_TIME

TDWTime

SQL_TYPE_TIMESTAMP

TDWTimestamp

Date, Time and DateTime Types

The associated SQL types for date, time, and datetime are listed below:

Type SQL Type for ODBC 3.x

date

SQL_TYPE_DATE

time

SQL_TYPE_TIME

datetime

SQL_TYPE_TIMESTAMP

Important:

SQL_DATE, SQL_TIME and SQL_TIMESTAMP are ODBC 2.x types, while SQL_TYPE_DATE, SQL_TYPE_TIME, and SQL_TYPE_TIMESTAMP are ODBC 3.x types. Since you are developing an ODBC 3.x driver, use the ODBC 3.x types.

 

Example: Simple Fixed-Length Data

The SQLData for a SQL_INTEGER contains a simba_int32 type. This example shows you how to copy your integer value into the simba_int32 type.

switch (in_data->GetMetadata()->GetSqlType())

{

    case SQL_INTEGER:

    {

        simba_int32 value = 1234;

        *reinterpret_cast<simba_int32*>(in_data->GetBuffer()) = value;

    }

}

Variable Length Types

The following variable-length data types are stored in buffers and represented by SqlData objects:

SQL Type Data Type

SQL_BINARY

simba_byte*

SQL_CHAR

simba_char*

SQL_LONGVARBINARY

simba_byte*

SQL_LONGVARCHAR

simba_char*

SQL_VARBINARY

simba_byte*

SQL_VARCHAR

simba_char*

SQL_WCHAR

simba_byte*

SQL_WLONGVARCHAR

simba_byte*

SQL_WVARCHAR

simba_byte*

Note:

You can use DSITypeUtilities::OutputWVarCharStringData and OutputVarCharStringData for setting character data.

Example: Variable-Length Data

In the example below, the SQL_CHAR case shows how to use the type utilities, while the SQL_VARCHAR case shows how to use memcpy.

Note:

  • In your custom driver code, SQL_CHAR, SQL_VARCHAR and SQL_LONGVARCHAR do not require separate cases.
  • You custom driver code has other considerations, such as handling offsets in the data.

switch (in_data->GetMetadata()->GetSqlType())

{

    case SQL_CHAR:

    {

        simba_string stdString(“Hello”);

        return DSITypeUtilities::OutputVarCharStringData(

            &stdString,

            in_data,

            in_offset,

            in_maxSize);

    }

    case SQL_VARCHAR:

    {

       simba_string stdString("Hello");

       simba_uint32 size = stdString.size();

    in_data->SetLength(size);

    memcpy(in_data->GetBuffer(), stdString, size);

    return false;

    }

}