When bulk reading a database column that allows NULL values, you must check for null in the receiving vector object.

Article ID: 1188
Last updated: 31 Jan, 2008
Article ID: 1188
Last updated: 31 Jan, 2008
Revision: 1
Views: 3480
Posted: 26 Jun, 2001
by Dean J.
Updated: 31 Jan, 2008
by Dean J.
Problem


When checking the output of an RWDBBulkReader, some of the data which should be null in the receiving RWDBVector contains incorrect, non-null values.


Cause


This issue is most often caused by a program that does not check for null values in the receiving RWDBVector, RWDBDateVector or RWDBStringVector objects when processing the results of an RWDBBulkReader.


Action


To avoid this issue in your program, check each element of the RWDBVector, RWDBDateVector or RWDBStringVector objects mapped to a column in your database the allows NULL values.  An example of this checking can be found in the following code sample.

#code

  RWDBTable mlTable1 = mlResult1.table();
  RWDBBulkReader mlBReader = mlTable1.bulkReader(mlConnection1);

  RWDBVector<int> nNumber (1);
  RWDBStringVector szText (1000, 1);

  mlBReader << nNumber << szText;

  int nRead = 0;
  while (nRead = mlBReader())
  {
   cerr << "Read " << nRead << " record(s)" << endl;;

   for (int i = 0; i < nRead ; i++)
   { 
    cout << " nNumber[" << i << "] = " << nNumber[i]
      << " | szText[" << i << "] = " << (szText.isNull(i) ? "NULL" : szText[i])
       << " | Len " << szText.length() << endl << endl;
    
   }
   }

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1188
Last updated: 31 Jan, 2008
Revision: 1
Views: 3480
Posted: 26 Jun, 2001 by Dean J.
Updated: 31 Jan, 2008 by Dean J.

Others in this category