[Paraview] vtkODBCDatabase and Oracle

Nehme Bilal nehmebilal at gmail.com
Fri Oct 14 20:03:28 EDT 2011


Hello all,

I am trying to create a ParaView reader (or source) that uses
vtkODBCDatabase to connect and read data from an
Oracle Database.

I compiled ParaView 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 "Number" data 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 a Number-> ok = false this time.
       bool ok = sqlQuery->DataValue(1).IsValid();
}

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

I also tried "float" columns and it works. It seems that the problem
happens only with "Number".

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


Thanks,

Nehme


More information about the ParaView mailing list