Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWDBColumn

Module:  DB Interface Module   Group:  Database Classes


Does not inherit

Local Index

Members

Synopsis

#include <rw/db/column.h>

RWDBColumn c = myTable["columnName"];

Description

RWDBColumn provides a way to refer to a particular column of a table or schema, or to a particular parameter of a stored procedure. An application obtains instances of RWDBColumn by indexing into an RWDBTable or RWDBSchema.

RWDBColumn instances may be used in expressions (see RWDBExpr), which in turn are used to build up encapsulated SQL objects such as RWDBSelector.

RWDBColumn instances are also used in RWDBSchema. An RWDBSchema is a collection of RWDBColumns used to describe a database table, view, or stored procedure. When used in this way, RWDBColumn stores several pieces of information:


NOTE -- The DB Interface Module does not obtain schema information until it is required. See RWDBTable::fetchSchema.

If no schema information has been obtained for the table containing a column, the column will contain default values. For Native Type, Storage Length, Precision, and Scale, this default value is RWDB_NO_TRAIT, and may be used in conditional expressions as follows:

RWDBColumn is designed around the Interface/Implementation paradigm. An RWDBColumn instance is an interface to a reference-counted implementation; copy constructors and assignment operators produce additional references to a shared implementation. Unlike many classes in the DB Interface Module, RWDBColumn implementations do not require database-specific variants.

About Precision and Scale

Precision and scale are used when defining numeric data types. Each database applies these specifications to data types in a slightly different manner. For example, Sybase applies precision and scale to decimal and numeric data types, while Oracle applies precision and scale to numeric data types only.

The precision of a column defines the total precision of the data type. For decimal data types, this translates into the total number of base ten digits. For floating point data types, this translates into binary digits or size.

The scale of a column defines the precision of the fractional part of the data type. For decimal data types, this translates into the total number of digits following the decimal point.

Note that precision and scale are often optional for a data type and that many databases apply default sizes when precision and scale are not provided.

For applications written with the DB Interface Module, precision and scale should always be specified if an application will create columns of a certain precision and scale. A DB Access Module can either disregard or use the necessary information in order to create a column of the correct data type. Typically, precision and scale should always be given for decimal columns.

Related Classes

RWDBColumn is commonly used to construct encapsulated SQL expressions, which can in turn become part of encapsulated SQL statements like RWDBSelector, RWDBInserter, RWDBDeleter, and RWDBUpdater. For example, to create an encapsulation of the SQL statement:

UPDATE myTable SET myColumn = 10 WHERE myKey < 100

we would write:

Note that the index expressions myTable["myColumn"] and myTable ["myKey"] result in the construction of RWDBColumn instances, which are then used to construct instances of an RWDBAssignment and RWDBExpr, respectively.

For additional details, see RWDBExpr, RWDBAssignment, RWDBCriterion, RWDBSelector, RWDBInserter, RWDBUpdater, and RWDBDeleter.

Public Enum

enum ParamType { notAParameter, inParameter, outParameter,
                 inOutParameter };

Public Constructors

RWDBColumn();
RWDBColumn(const RWDBColumn& column);

Public Member Operator

RWDBColumn&
operator=(const RWDBColumn& column); 

Public Member Functions

void
acquire() const;
RWDBAssignment
assign(const RWDBExpr& expression) const; 
RWDBAssignment
assign(char value) const;
RWDBAssignment
assign(unsigned char value) const;
RWDBAssignment
assign(short int value) const;
RWDBAssignment
assign(unsigned short int value) const;
RWDBAssignment
assign(long int value) const;
RWDBAssignment
assign(unsigned long int value) const;
RWDBAssignment
assign(int value) const;
RWDBAssignment
assign(unsigned int value) const;
RWDBAssignment
assign(long long value) const;
RWDBAssignment
assign(unsigned long long value) const;
RWDBAssignment
assign(float value) const;
RWDBAssignment
assign(double value) const;
RWDBAssignment
assign(long double value) const;
RWDBAssignment
assign(const char* value) const;
RWDBAssignment
assign(const RWCString& value) const;
RWDBAssignment
assign(const RWDate& value) const;
RWDBAssignment
assign(const RWTime& value) const;
RWDBAssignment
assign(const RWDateTime& value) const;
RWDBAssignment
assign(const RWDBDateTime& value) const;
RWDBAssignment
assign(const RWDBDuration& value) const;
RWDBAssignment
assign(const RWDecimalPortable& value) const;
RWDBAssignment
assign(const RWDBBlob& value) const;
RWDBAssignment
assign(const RWDBExpr& expr) const;
RWDBAssignment
assign(const RWDBMBString& value) const;
RWDBAssignment
assign(const RWWString& value) const;
RWDBAssignment
assign(const wchar_t* value) const;
RWDBAssignment
assign(const RWDBValueManip manip) const;
RWDBAssignment
assign(const RWBasicUString& value) const;

NOTE -- This function accepts Unicode strings. For more information, see the entry for RWBasicUString in the Essential Tools Module Reference Guide. For more information on internationalization, see Chapter 13 of the DB Interface Module User's Guide.
RWDBCriterion
between(const RWDBExpr& expression1, 
        const RWDBExpr& expression2) const; 
RWDBColumn&
clearTable();
RWDBColumn
clone() const;
RWDBStatus::ErrorHandler
errorHandler() const;
RWDBCriterion
in(const RWDBExpr& expression) const;
bool
isEquivalent(const RWDBColumn& column) const;
RWDBCriterion 
isNull(void) const;
bool
isValid() const;
RWDBCriterion
leftOuterJoin(const RWDBExpr& expression) const;
RWDBCriterion
like(const RWDBExpr& expression) const;
RWDBCriterion
matchUnique(const RWDBExpr& expression) const;
RWCString
name() const;
RWDBColumn&
name(const RWCString& newName);
int
nativeType() const;
RWDBColumn&
nativeType(int newType);
bool
nullAllowed() const;
RWDBColumn&
nullAllowed(bool nullAllowed);
RWDBColumn::ParamType
paramType() const;
RWDBColumn&
paramType(RWDBColumn::ParamType type);
int
precision() const;
RWDBColumn&
precision(int precision);
RWCString
qualifiedName() const;
void
release() const;
RWDBCriterion
rightOuterJoin(const RWDBExpr& expression) const;
int
scale() const;
RWDBColumn&
scale(int scale);
void
setErrorHandler(RWDBStatus::ErrorHandler handler);
RWDBStatus
status() const;
long
storageLength() const;
RWDBColumn&
storageLength(long newLength);
RWDBTable
table() const;
RWDBColumn&
table(const RWDBTable& table);
RWDBValue::ValueType
type() const;
RWDBColumn&
type(RWDBValue::ValueType type);


Previous fileTop of DocumentContentsIndex pageNext file

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