rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWDBNullIndicator Class Reference
[Data Types]

Provides a way to determine whether some given data is NULL. More...

#include <rw/db/nullind.h>

List of all members.

Public Member Functions

 RWDBNullIndicator (bool value=0)
 operator bool () const

Detailed Description

RWDBNullIndicator allows application code:

An RWDBNullIndicator instance may be interpreted as a boolean value: true means a data item is NULL; false means a data item is not NULL.

Synopsis

 #include <rw/db/nullind.h>

 RWDBNullIndicator nullInd;

Related Classes

RWDBNullIndicator is designed specifically to detect NULL values as they are extracted from an RWDBReader. See RWDBReader for more details.

The setting of RWDBDatabase::emptyStringIsNull can affect the way that empty strings are inserted and read. For more details, see RWDBManager::emptyStringIsNull(bool).

Examples

This code fragment selects an integer and a string from a table, and checks for NULL before processing the results:

 RWDBTable myTable = myDBase.table("myTable");
 RWDBSelector select = myDBase.selector();
 select << myTable["id"] << myTable["name"];
 RWDBReader rdr = select.reader();
 int id;
 RWCString name;
 RWDBNullIndicator idIsNull;
 RWDBNullIndicator nameIsNull;

 while (rdr()) {
   rdr >> idIsNull >> id >> nameIsNull >> name;
   if (idIsNull || nameIsNull) {
     // handle NULL case
   }
   else {
     // process name and id normally
   }
 }

Constructor & Destructor Documentation

RWDBNullIndicator::RWDBNullIndicator ( bool  value = 0  )  [inline]

Constructs an RWDBNullIndicator with the given initial value.


Member Function Documentation

RWDBNullIndicator::operator bool (  )  const [inline]

Returns the current boolean value of self.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.