In the Data Store Interface (DSI), the following methods perform the actual task of retrieving data from your data store:
Both methods provide a way to uniquely identify a column within the current row. For
QSTable, the Simba SQL Engine will pass in the column index
In addition, both methods accept the following three parameters:
GetBuffer()method. The data you copy into the buffer must be formatted as a SQL Type (see for a list of data types and definitions). Therefore, if your data is not stored as SQL Types, you will need to write code to convert from your native format.
QSTable:: InitializeColumns()to SQL_INTEGER, then when
TabbedUnicodeFileReader::GetData()is called for column 1, you will be passed a SQLData that wraps an int data type. For MetadataSource, the type is associated with the column tag (see
SqlData was of type
simba_int32 value = 5;
//This is one way
memcpy(in_data->GetBuffer(), &value, sizeof(simba_int32));
// This is another way; both work equally well
*reinterpret_cast<simba_int32*>(in_data->GetBuffer()) = 5;
When working with variable length data, for example character or binary data, you must call
SetLength() before calling
GetBuffer(). Not doing so may result in a heap violation. See
QSTypeUtilities.h for an example on how to handle character or binary data.
in_dataparameter. For character or binary data, copying data that is greater than this size can result in a data truncation warning or a heap violation.
SqlData objects represent the SQL types and encapsulate the data in a buffer. To get the underlying SQL type that a
SqlData object represents, use
GetMetadata()->GetSqlType(). This retrieves the associated
For information on how SQL types map to C++ types, see SQL Data Types in Developing Drivers for Data Stores Without SQL
In the QuickStart example, when
GetData() is called the values are read from the tabbed Unicode file (in TabbedUnicodeFileReader::GetData), converted to
QSTable::ReadWholeColumnAsString) and then converted to the requested SQL data type (in
QSTable::ConvertData). This works well because the data source is a text file and a good cross-platform example.
For your data source, if you’re already getting data of the correct type—integers, for example—then ideally you should skip the conversion to strings so you can achieve better performance. Be aware of which data types map to which SQL Types, as well as how to represent them in the expected format. Then you can set the buffer in an appropriate manner.
To represent a null value, directly set the
SqlData object as null: