TTXlaRowViewer Reference

TTXlaRowViewer, which represents a row image from change notification records, is used to examine XLA change notification record structures and old and new column values.

Public Members

None

Public Methods

This section summarizes then describes the TTXlaRowViewer public methods.

Public Methods Summary

Method Description

columnPrec()

Returns the precision of the specified column in the row image.

columnScale()

Returns the scale of the specified column in the row image.

Get()

Fetches the value of the specified column in the row image.

getColumn()

Returns the specified column from the row image.

isColumnTTTimestamp()

Indicates whether the specified column in the row image is a TT_TIMESTAMP column.

isNull()

Indicates whether the specified column in the row image has the value NULL.

numUpdatedCols()

Returns the number of columns in the row image that have been updated.

setTuple()

Associates the TTXlaRowViewer object with the specified row image.

updatedCol()

Returns the column number in the row image of a column that has been updated, typically during iteration through all updated columns.

columnPrec()

SQLULEN columnPrec(int cno)

Returns the precision of data in column number cno of the row image, referring to the maximum number of digits that are used by the data type.

columnScale()

int columnScale(int cno)

Returns the scale of data in column number cno of the row image, referring to the maximum number of digits to the right of the decimal point.

Get()

void Get(int cno, TYPE* valueP)
void Get(int cno, TYPE* valueP, SQLULEN* byteLenP)

Fetches the value of column number cno in the row image. These methods are very similar to the TTCmd::getColumn() methods.

Table 5-1 shows the supported SQL data types and the appropriate versions of Get() to use for each data type. Design the application according to the types of data that are stored. For example, data of type NUMBER(9,0) can be accessed by the Get(int, int*) method without loss of information.

Table 5-1 Get() Signatures for Supported Table Column Types

XLA Data Type Database Data Type Get() Variant

TTXLA_CHAR_TT

TT_CHAR

Get(int cno, char** cPP)

TTXLA_NCHAR_TT

TT_NCHAR

Get(int cno, SQLWCHAR** wcPP, SQLULEN* byteLenP)

TTXLA_VARCHAR_TT

TT_VARCHAR

Get(int cno, char** cPP)

TTXLA_NVARCHAR_TT

TT_NVARCHAR

Get(int cno, SQLWCHAR** wcPP, SQLULEN* byteLenP)

TTXLA_TINYINT

TT_TINYINT

Get(int cno, SQLTINYINT* iP)

TTXLA_SMALLINT

TT_SMALLINT

Get(int cno, short* iP)

TTXLA_INTEGER

TT_INTEGER

Get(int cno, int* iP)

TTXLA_BIGINT

TT_BIGINT

Get(int cno, SQLBIGINT* biP)

TTXLA_BINARY_FLOAT

BINARY_FLOAT

Get(int cno, float* fP)

TTXLA_BINARY_DOUBLE

BINARY_DOUBLE

Get(int cno, double* dP)

TTXLA_TIME

TT_TIME

Get(int cno, TIME_STRUCT* tP)

TTXLA_DATE_TT

TT_DATE

Get(int cno, DATE_STRUCT* dP)

TTXLA_TIMESTAMP_TT

TT_TIMESTAMP

Get(int cno, TIMESTAMP_STRUCT* tsP)

TTXLA_BINARY

BINARY

Get(int cno, const void** binPP, SQLULEN* byteLenP)

TTXLA_VARBINARY

VARBINARY

Get(int cno, const void** binPP, SQLULEN* byteLenP)

TTXLA_NUMBER

NUMBER

Get(int cno, double* dP)
Get(int cno, char** cPP)
Get(int cno, short* iP)
Get(int cno, int* iP)
Get(int cno, SQLBIGINT* biP)

TTXLA_DATE

DATE

Get(int cno, TIMESTAMP_STRUCT* tsP)

TTXLA_TIMESTAMP

TIMESTAMP

Get(int cno, TIMESTAMP_STRUCT* tsP)

TTXLA_CHAR

CHAR

Get(int cno, char** cPP)

TTXLA_NCHAR

NCHAR

Get(int cno, SQLWCHAR** wcPP, SQLULEN* byteLenP)

TTXLA_VARCHAR

VARCHAR2

Get(int cno, char** cPP)

TTXLA_NVARCHAR

NVARCHAR2

Get(int cno, SQLWCHAR** wcPP, SQLULEN* byteLenP)

TTXLA_FLOAT

FLOAT

Get(int cno, double* dP)
Get(int cno, char** cPP)

TTXLA_BLOB

BLOB

Get(int cno, const void** binPP, SQLULEN* byteLenP)

TTXLA_CLOB

CLOB

Get(int cno, char** cPP)

TTXLA_NCLOB

NCLOB

Get(int cno, SQLWCHAR** wcPP, SQLULEN* byteLenP)

getColumn()

const TTXlaColumn* getColumn(u_int cno) const

Returns a TTXlaColumn object with metadata for column number cno in the row image.

isColumnTTTimestamp()

bool isColumnTTTimestamp(int cno)

Returns TRUE if column number cno in the row image is a TT_TIMESTAMP column, or FALSE otherwise.

isNull()

bool isNull(int cno)

Indicates whether the column number cno in the row image has the value NULL, returning TRUE if so or FALSE if not.

numUpdatedCols()

SQLUSMALLINT numUpdatedCols()

Returns the number of columns that have been updated in the row image.

setTuple()

void setTuple(ttXlaUpdateDesc_t* updateDescP, int whichTuple)

Before a row can be examined, this method must be called to associate the TTXlaRowViewer object with a particular row image. It is invoked inside the TTXlaTableHandler::HandleInsert(), HandleUpdate(), or HandleDelete() method, or by a user-written overloaded method. You would typically call it when overloading the TTXlaTableHandler::HandleChange() method. The TimesTen Classic Quick Start xlasubscriber1 demo provides an example of its usage. (See About TimesTen Quick Start and Sample Applications.)

The ttXlaUpdateDesc_t structures that are returned by TTXlaPersistConnection::fetchUpdatesWait() contain either zero, one, or two rows. Note the following:

  • Structures that define a row that was inserted into a table contain the row image of the inserted row.

  • Structures that define a row that was deleted from a table contain the row image of the deleted row.

  • Structures that define a row that was updated in a table contain the images of the row before and after the update.

  • Structures that define other changes to the table or the database contain no row images. For example, structures reporting that an index was dropped contain no row images.

The setTuple() method takes two arguments:

  • A pointer to a particular ttXlaUpdateDesc_t structure defining a database change

  • An integer specifying which type of row image in the update structure should be examined

    The following are valid values:

    • INSERTED_TUP: Examine the inserted row.

    • DELETED_TUP: Examine the deleted row.

    • UPDATE_OLD_TUP: Examine the row before it was updated.

    • UPDATE_NEW_TUP: Examine the row after it was updated.

updatedCol()

SQLUSMALLINT updatedCol(u_int cno)

Returns the column number of a column that has been updated. For the input parameter you can iterate from 1 through n, where n is the number returned by numUpdatedCols(). The example that follows shows a snippet from the TimesTen Classic Quick Start demo xlasubscriber1, where updatedCol() is used with numUpdatedCols() to retrieve each column that has been updated. (See About TimesTen Quick Start and Sample Applications.)

void
SampleHandler::HandleUpdate(ttXlaUpdateDesc_t* )
{
  cerr << row2.numUpdatedCols() << " column(s) updated: ";
  for ( int i = 1; i <= row2.numUpdatedCols(); i++ )
  {
    cerr << row2.updatedCol(i) << "("
         << row2.getColumn(row2.updatedCol(i)-1)->getColName() << ") ";
  }
  cerr << endl;
}