DB Interface Module User’s Guide
PART I Introduction
Introduction
Overview
Features and Benefits
Comprehensive Functionality
Consistency Across Different Databases
Enhanced Performance
Module-Specific Software Requirements
Compatibility
Dependencies
Database Connectivity
Database Knowledge
Examples
Products and Services Information
Design Overview
Basic Architecture
Interface and Implementation Classes
Database-Dependent and Database-Independent Interface Classes
Producers and Products
Reference Semantics
Memory Allocation
Information Flow
Class Overview
Kinds of Classes
Datatype Classes
Database Classes
Data Manipulation Classes
Expression Classes
Bulk Classes
Open SQL Classes
Utility and Diagnostics Classes
Callback Classes
Summary of Classes
Member Function Conventions
PART II Using the Basic Features
The Database Classes
Before You Log On
Getting a Connection
Managing Connections
RWDBDatabase and RWDBConnection
Explicit and Implicit Connections
Connection Pools
Alternatives for Managing Connections
Transaction Processing with RWDBConnection
Transaction Control and Locking
Tables
Database Tables
Reading Tables: Class RWDBReader
Overloading the Extraction Operator
Derived Tables
Memory Tables
Result Tables
Summary
Table Constraints
Table Constraints Classes
Column Level Constraints
Not Null Constraints
Default Column Constraints
Identity Column Constraints
Table Level Constraints
Primary Key Constraints
Foreign Key Constraints
Unique Table Constraints
Check Table Constraints
Working with Table Level Constraints
Creating Tables with Constraints
Adding or Dropping Constraints
Fetching Table Constraints
The Data Manipulation Classes
More on Basic Classes
Expressions, Criteria, and Assignments
Creating WHERE Clauses and Check Constraints
RWDBCriterion and RWDBExpr
Assigning New Values to Table Columns
Creating CASE Expressions
Simple CASE Expressions
Searched CASE Expressions
Summary
Selecting Data
Selecting Data from a Single Table
Joins
Outer Joins
Outer Join Constructs in the FROM Clause (ANSI-Compliant)
Outer Join Constructs In the WHERE Clause (ANSI-Noncompliant)
Composing FROM Clause
Ordering and Grouping
Aggregates, Expressions, and Functions
Self-Joins
Subqueries
Summary
Inserting Data
Inserting Values
Inserting with a Selector
Inserting with a Reader
Getting Results from an Inserter
A Note About Connections
Summary
Updating Data
Subqueries and Correlated Updates
Use of Table Tags when Updating
Deleting Data
Subqueries and Correlated Deletes
Use of Table Tags when Deleting
Stored Procedures
Instantiating RWDBStoredProc
Type and Error Checking in RWDBStoredProc
Complex Stored Procedure Example
Cursors
Instantiating an RWDBCursor
Bind Operations
Fetch Operation
Insert Operation
Delete Operation
Update Operation
asString() Methods in the Data Manipulation Classes
Summary
The Error Model
Overview
Checking Status with Class RWDBStatus
Error Handlers
Exceptions
More About Error Handlers
Kinds of Errors
Capturing Database-Dependent Information
More About isValid()
Defining a Valid Object
Making Unusable Objects Usable
Summary
The Data Model
The Problem of Diverse Data Types
The SourcePro DB Solution
The Database Layer
The Value Layer
RWCString
RWDateTime
Example
Constructors
RWTimeTuple and RWTimeTupleOffset
RWDBDuration
RWDBBlob
RWDecimalPortable
RWDBValue
Internationalization Data Types
The Pointer Layer
Summary
PART III Using Advanced Features
Bulk Reading and Writing
The Bulk Classes
Examples with Bulk Classes
Bulk Read and Writes
Bulk Classes and RWDBBlob
Caching
Caching and Performance
A Database Client Perspective
Caching When Inserting and Reading Data
Caching with RWDBInserter
Caching with RWDBReader
Restrictions On Caching with RWDBReader, RWDBInserter
Result Schema Caching
Metadata Caching and the Cache Manager
Types of Cacheable Data
Using the Cache Manager
Error Handling in the Cache Manager
Keeping the Cache Up-To-Date
The In-Memory Cache Manager
Implementing a Cache Manager
Example
Database and Connection Callbacks
Callback Functionality
Callback Locations
Callback Classes
Implementing Callbacks
Implementing Database Callbacks
Providing a Password using connParams()
Implementing Connection Callbacks
Callback Sequence
Callback sequence for a database callback and explicit connection callback
Callback sequence for a database callback producing a connection callback
Callback Example
Multithreading
The DB Interface Module and Multithread Safety
Levels of Multithread Support
Sharing Objects of the DB Interface Module Among Threads
Sharing an RWDBConnection
Database-Independent Classes
The Guard Class with Templates
Guard Classes Without Templates
Portable Guard Classes
Asynchronous Usage
Definition
Architectural Overview
Handling Asynchronous Call Completions
RWDBStatus Behavior in the Asynchronous Context
Asynchronous Usage Example
Handling C++ Datatype Returns from an Asynchronous Call
Asynchronous Calls in the DB Interface Module
Running Many Asynchronous Calls on a Single RWDBConnection
Performance Issues
Asynchronous RWDBReaders
Internationalization
Definition
Character Sets
National Character Sets and C++ Data Types
RWBasicUString
RWWString
RWDBMBString
RWCString
Data Definition Language
Using Schema Information from Result Tables
Data Formatting
RWDateTime
RWDate
RWDecimalPortable
Formatting Raw Numbers
PART IV Using Open SQL
Defining Open SQL
An Alternative API
Who Should Use Open SQL
A Summary of the Open SQL Classes
Open SQL and the Standard API
Using the Open SQL Classes
Class RWDBOSql
Creating an RWDBOSql Instance
Providing an SQL Statement
Statement Type Hint
Executing the SQL Statement
Error Handling
Obtaining the Results
Class RWDBTBuffer<T>
Instantiating RWDBTBuffer
Memory Management in RWDBTBuffer
Output Binding and Fetching Using RWDBTBuffer
Using RWDBTBuffers for Input
Bulk/Array Input
The Data Callback Classes
Fetching Data
Inserting Data
Implementing a Custom Callback Class
Implementing onFetch()
Implementing onSend()
Implementing getLength()
Using a Custom Callback Class with Open SQL
Fetching Data with a Custom Callback Class
Inserting Data with a Custom Callback Class
Other Resources
RWDBMultiRow
Using RWDBMultiRow for Ad Hoc Queries
Obtaining Data from RWDBMultiRow
PART V The Tutorials
A Tutorial Overview
Introduction
List of Tutorials
Setting up the Tutorials
The Tutorial Model
Retrieving Data from a Table
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVContactRepository Constructor
VVContactRepository::mailingLabels
operator>>() for VVContact
Retrieving Data Selectively
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVContactRepository::mailingLabels
VVContactRepository::reader
Conclusion
Inserting Data into a Table
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVContactRepository::insert
operator<<() for VVContact
Conclusion
Inserting and Updating Data
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVVideoRepository::updateStock
Conclusion
Deleting Rows from a Table
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVContactRepository::remove
Conclusion
A Complicated Query
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
Conclusion
Updating Data in Multiple Tables
Goal of This Tutorial
Overview of This Tutorial
Running the Program
Checking the Output
The Program
The Main Routine
VVInvoice::addRental
VVVideoRepository::find
VVVideoRepository::update
Appendix A, Glossary
Terms and Definitions
DB XA Module User’s Guide
Introduction
Overview
Product Features
Module-Specific Software Requirements
Establishing Connectivity with the DB XA Module
Products and Services Information
Overview
The Abstract X/Open DTP Model
The DB XA Module in the X/Open DTP Environment
Class Overview
The DB XA Module Classes
Database Class Enhancements
RWDBDatabase
RWDBConnection
Using the DB XA Module Database Classes
Database Classes in the DB XA Module
Getting Connected with the DB XA Module
Databases and Connections
Managing Connections
Transaction Processing
Using the DB Access Modules With XA Functionality
Overview
Oracle OCI Access Module
Configuring the Resource Manager
Switch Table
Databases and Connections
RWDBDatabase Objects
RWDBSystemHandle and RWDBEnvironmentHandle
Sybase Access Module
Configuring the Resource Manager
Switch Table
Databases and Connections
RWDBDatabase Objects
RWDBConnection Objects
The Contents of RWDBSystemHandle
The Contents of RWDBEnvironmentHandle
DB2 CLI Access Module
Configuring the Resource Manager
Switch Table
Databases and Connections
RWDBDatabase Objects
The Contents of RWDBSystemHandle
The Contents of RWDBEnvironmentHandle
Writing Applications with the DB XA Module
Overview
Designing Programs for the X/Open Environment
Moving from the DB Interface Module to the DB XA Module
Using Data Definition Language
Using SQL Statements through RWDBConnection::executeSQL()
Mixing XA and Non-XA Connections
Appendix A, Glossary
Terms and Definitions
DB Access Module for DB2 CLI User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of DB Interface Module Datatypes
Expressions
Global Functions
Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Cursors
Caching
Inserter Caching
Reader Caching
BulkReader and BulkInserter
Support
Updater and Deleter
Use of Table Tags
Stored Procedures
Creating Stored Procedures
Executing Stored Procedures
Instantiating an RWDBStoredProc Using Schema Data
Internationalization
Data Bindings
Limitations
Metadata
Use of RWWString in Unicode Applications
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Error Messages
Errors and RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Input Binding of Data
System and Environment Handles to DB2 CLI Specific Resources
Open SQL and DB2 CLI
Placeholder Syntax
RWDBDataCallback and Open SQL
Piece Size Setting
RWDBDataCallback::getLength()
Stored Procedures and RWDBDataCallback
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Executing Cancel in Open SQL
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
Using Static Libraries with DB2 CLI Access Module and MS SQL Server Module
Callbacks
Appendix A, System Tables and Functions
System Tables
System Functions
DB Access Module for Microsoft SQL Server User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of Datatypes
Expressions
Global Functions
Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Cursors
Caching
Inserter Caching
Reader Caching
BulkReader and BulkInserter
Support
Updater and Deleter
Use of Table Tags
Stored Procedures
Creating Stored Procedures
Executing Stored Procedures
Instantiating an RWDBStoredProc Using Schema Data
Internationalization
Prerequisites
Data Bindings
Limitations
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Error Messages
Errors and ODBC Conformance
Errors and RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Using Text and Image Data
Input Binding of Data
System and Environment Handles to Microsoft SQL Server Specific Resources
Open SQL and Microsoft SQL Server ODBC
Placeholder Syntax
RWDBDataCallback and Open SQL
Piece Size Setting
RWDBDataCallback::getLength()
Stored Procedures and RWDBDataCallback
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Executing Cancel in Open SQL
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
Using Static Libraries with MS SQL Server and DB2 CLI Access Modules
Callbacks
Appendix A, System Tables and Functions
System Tables
System Functions
DB Access Module for MySQL User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of Datatypes
Expressions
Global Functions
Outer Joins
Full Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Check Constraints
Adding or Dropping Constraints
Cursors
Caching
BulkReader and BulkInserter
Updater and Deleter
Use of Table Tags
Stored Procedures
Creating Stored Procedures
Executing Stored Procedures
Instantiating an RWDBStoredProc Using Schema Data
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Internationalization
Error Messages
Errors
Errors and RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Input Binding of Data
System and Environment Handles to MySQL Specific Resources
Open SQL and MySQL
Placeholder Syntax
RWDBDataCallback and Open SQL
Executing Cancel in Open SQL
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
Callbacks
Appendix A, System Tables
System Tables
DB Access Module for ODBC User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of Datatypes
Expressions
Table and Column Names
Global Functions
Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Unique and Check Constraints
Cursors
Caching
Inserter Caching
Reader Caching
BulkReader and BulkInserter
Updater and Deleter
Use of Table Tags
Stored Procedures
Instantiating an RWDBStoredProc Using Schema Data
Transactions
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Internationalization
Prerequisites
Data Bindings
Limitations
Error Messages
Errors and ODBC Conformance
Errors and RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Input Binding of Data
System and Environment Handles to ODBC Specific Resources
Open SQL and ODBC
Placeholder Syntax
RWDBDataCallback and Open SQL
Piece Size Setting
RWDBDataCallback::getLength()
Stored Procedures and RWDBDataCallback
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Executing Cancel in Open SQL
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
Callbacks
Appendix A, System Views
System Views
DB Access Module for Oracle OCIUser’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of Datatypes
Expressions
Global Functions
rwdbCast()
Outer Joins
Table and Column Constraint Limitations
Identity Column Constraints
Cursors
Caching
Updater and Deleter
Use of Table Tags
BulkReader and BulkInserter
Stored Procedures
Creating a Stored Procedure
Input/Output Parameters and Result Sets
Instantiating an RWDBStoredProc Using Schema Data
Internationalization
Prerequisites
Environment Variables
Database NLS_NCHAR_CHARACTERSET
Database Length Semantics
Data Bindings
Limitations
Using Oracle Datatypes NCHAR and NVARCHAR2
Metadata
Using RWWString in Unicode Applications
Using RWDBMBString in Unicode Applications
Date Formats
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Error Messages: Contents of RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Large Character and Binary Data
Input Binding of Data
Output Binding of Data
System and Environment Handles to Oracle OCI Specific Resources
Open SQL and Oracle OCI
Placeholder Syntax
Supported Datatypes for Output Binding
RWDBDataCallback and Open SQL
Piece Size Setting
RWDBDataCallback::getLength()
Stored Procedures and RWDBDataCallback
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Executing Cancel in Open SQL
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
OCIStmts
Simultaneous Processing of Results on an RWDBOSql Object When Used for Stored Procedure
Callbacks
Appendix A, System Tables, Views, and Functions
System Tables
System Views
System Functions
DB Access Module for PostgreSQL User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Examples of Opening a Database
Datatypes
Restrictions on the Use of Datatypes
Serial Columns in Tables
Expressions
Global Functions
Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Cursors
Caching
Inserter Caching
Reader Caching
Updater and Deleter
BulkReader and BulkInserter
Stored Procedures
Creating a Stored Procedure
Executing a Stored Procedure
Instantiating an RWDBStoredProc Using Schema Data
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Internationalization
Error Messages
Errors and RWDBStatus
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Input Binding of Data
System and Environment Handles to PostgreSQL Specific Resources
Open SQL and PostgreSQL
Placeholder Syntax
RWDBDataCallback and Open SQL
Stored Procedures and Open SQL
Out Parameters and Return Values
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
Open SQL Stored Procedure Examples
Executing Cancel in Open SQL
Callbacks
Handling SQL Escape Strings
Appendix A, System Tables and Functions
System Tables
System Functions
DB Access Module for Sybase User’s Guide
Introduction
Overview
Technical Information
Introduction
Databases and Connections
Datatypes
Restrictions on the Use of Datatypes
Expressions
Global Functions
Joins
Outer Joins
Table and Column Constraint Limitations
Identity Constraints
Caching
Inserter Caching
Reader Caching
Cursors
Updater and Deleter
BulkReader and BulkInserter
Using an RWDBBulkInserter
Stored Procedures
Creating a Stored Procedure
Executing Stored Procedures
Instantiating an RWDBStoredProc Using Schema Data
Internationalization and Localization
Prerequisites
Changing Locales on the Fly
Data Binding
Limitations
RWWString
Date Formats
Transaction Processing
Setting Isolation Levels
Using Transaction Control Methods
Error Messages: Contents of RWDBStatus
Reporting Errors from Client-Library and CS‑Library
Reporting Errors from Adaptive Server
Result Sets
Simultaneous Processing of Results from Multiple Statements Using the Same Connection
Text and Image Data
Input Binding of Data
Output Binding of Data
System and Environment Handles to Sybase Specific Resources
Open SQL and Sybase Open Client Client-Library
Placeholder Syntax
Supported Datatypes for Input Binding
Supported Datatypes for Output Binding
Bulk Inserts and Bulk Input Binding
RWDBDataCallback and Open SQL
Piece Size Setting
Changing the Maximum Fetch Size
RWDBDataCallback::getLength()
Stored Procedures and RWDBDataCallback
Stored Procedures and Open SQL
Sequence of Fetching Result Sets and Out Parameters
Simultaneous Result Processing
Simultaneous Results Processing of RWDBOSql Objects on the Same Connection
Simultaneous Results Processing of High-Level Objects of the DB Interface Module Using the Same Connection
Executing Cancel in Open SQL
Open SQL Examples
An Open SQL Insert Example
Open SQL Query Examples
An Open SQL Stored Procedure Example
Callbacks
Appendix A, System Tables, Functions and Variables
System Tables
System Functions
System Variables
DB Interface Module User’s Guide
System Variables