[vtkusers] vtkODBCDatabase and Oracle

Nehme Bilal nehmebilal at gmail.com
Thu Oct 13 17:08:31 EDT 2011


Hello all,

I am trying to use vtkODBCDatabase to connect and read data from an
Oracle Database.
I compiled VTK with :
VTK_USE_ODBC ON
ODBC_INCLUDE_DIRECTORIES C:/Program Files (x86)/Microsoft
SDKs/Windows/v7.0A/Include
ODBC_LIBRARY C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib/odbc32.lib

The connection is working correctly:

vtkODBCDatabase* db = vtkODBCDatabase::New();
vtkStdString dataSourceName ="DRIVER={Microsoft ODBC for
Oracle};SERVER=localhost:1521/xe/;";
db->SetDataSourceName(dataSourceName.c_str());
db->SetUserName("user");
bool status = db->Open("password");

To get a specific table from the database and information about the
columns I do:

vtkSQLQuery* sqlQuery = db->GetQueryInstance();
vtkStdString query = "select * from " + vtkStdString(tableName);
sqlQuery->SetQuery(query.c_str());
sqlQuery->Execute();

for(int j=0; j<sqlQuery->GetNumberOfFields(); ++j)
{
	vtkStdString fieldName = sqlQuery->GetFieldName(j);
	int fieldType = sqlQuery->GetFieldType(j);
}

All that is working very well. The problem happens when I try to read
values of Numeric type:

 while(sqlQuery->NextRow())
{
	// the first column is a "string" so it works -> ok = true
	bool ok = sqlQuery->DataValue(0).IsValid();

	// the second value is numeric -> ok = false this time.
	bool ok = sqlQuery->DataValue(0).IsValid();
}

Reading a numeric value from a row is returning an invalid vtkVariant.
Any ideas ?

I created the table with a query like:
CREATE TABLE Table1 (Name VARCHAR2 (40), Value NUMBER (38,8));


Thanks,

Nehme



More information about the vtkusers mailing list