SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWDBNullIndicator Class Reference

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

#include <rw/db/nullind.h>

Public Member Functions

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

Detailed Description

RWDBNullIndicator allows application code:

  • to determine whether a particular piece of data extracted from an RWDBReader is NULL
  • to specify whether a bound value is NULL when using an RWDBBoundExpr

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>
Provides a way to determine whether some given data is NULL.
Definition nullind.h:86
See also

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).

Example

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 nameIsNull;
while (rdr()) {
rdr >> idIsNull >> id >> nameIsNull >> name;
if (idIsNull || nameIsNull) {
// handle NULL case
} else {
// process name and id normally
}
}
Offers powerful and convenient facilities for manipulating strings.
Definition stdcstring.h:826
Provides row-by-row access to tabular data.
Definition reader.h:136
Encapsulates the SQL SELECT statement.
Definition select.h:369
Base class for a family of classes that represent the abstract notion of a database table in a number...
Definition table.h:89

Constructor & Destructor Documentation

◆ RWDBNullIndicator()

RWDBNullIndicator::RWDBNullIndicator ( bool value = 0)
inline

Constructs an RWDBNullIndicator with the given initial value.

Member Function Documentation

◆ operator bool()

RWDBNullIndicator::operator bool ( ) const
inline

Returns the current boolean value of self.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.