ヘッダーをスキップ
Oracle TimesTen In-Memory Database C開発者およびリファレンス・ガイド
リリース7.0
E05164-03
  目次へ
目次
索引へ
索引

前へ
前へ
次へ
次へ
 

データ・ストア間での表の互換性の確認

データ・ストア間で更新レコードを送信する場合は、マスター・データ・ストアとサブスクライバ・データ・ストアの表に互換性があることを確認します。

ttXlaTableByNamettXlaGetTableInfoおよびttXlaGetColumnInfo関数を使用して、表とその列の記述を確認できます。「表および列の記述の確認」を参照してください。

ttXlaVersionTableInfoおよびttXlaVersionColumnInfo関数を使用して、特定のXLAレコードの表および列のバージョンを確認できます。「表および列のバージョンの確認」を参照してください。

表および列の記述の確認

ttXlaTableByNamettXlaGetTableInfoおよび ttXlaGetColumnInfo関数を使用すると、レプリケートする各表のttXlaTblDesc_t および ttXlaColDesc_t記述が返されます。これらの処理については、「更新を監視する表の指定」および「列の記述の取得」を参照してください。これらの記述は、ttXlaTableCheck 関数に渡すことができます。出力パラメータcompatは、表に互換性があるかどうかを示します。値が1の場合は互換性があり、値が0(ゼロ)の場合は互換性がないことを示します。

次に例を示します。

SQLINTEGER compat;

ttXlaTblDesc_t table;

ttXlaColDesc_t columns[20];

rc = ttXlaTableCheck(xla_handle, &table, columns, &compat);

if (compat) {

     /* Go ahead and start replicating */

}

else {

    /* Not compatible or some other error occurred */

}

表および列のバージョンの確認

ttXlaVersionTableInfoおよびttXlaVersionColumnInfo関数を使用して、レコードの生成時に更新レコードの表構造の情報を取得します。

次の例では、pCmdソースのpXlaRecord更新レコードに関係付けられている表がhXlaTargetターゲットと互換性があることを確認します。

BOOL CUTLCheckXlaTable (SCOMMAND* pCmd,

                        ttXlaHandle_h hXlaTarget,

                        const ttXlaUpdateDesc_t* pXlaRecord)

{

  /* locals */

  BOOL bStatus = TRUE;

  SQLRETURN rc;

  ttXlaTblVerDesc_t tblVerDescSource;

  ttXlaColDesc_t colDescSource [255];

  SQLINTEGER iColumnCount = 0, iCompatible = 0;

  /* only certain update record types should be checked */

  if (pXlaRecord->type == INSERTTUP ||

    pXlaRecord->type == UPDATETUP ||

    pXlaRecord->type == DELETETUP)

  {

 /* get source table description associated with this record */

    /* at the time it was generated */

    rc = ttXlaVersionTableInfo (pCmd->pCtx->con->hXla,

      (ttXlaUpdateDesc_t*) pXlaRecord,

      &tblVerDescSource);

/* get the source column descriptors for this table */

    /* at the time the record was generated */

    if (bStatus)

    {

      SQLINTEGER iColsReturned = 0;

      rc = ttXlaVersionColumnInfo (pCmd->pCtx->con->hXla,

        (ttXlaUpdateDesc_t*) pXlaRecord,

        colDescSource, 255, &iColsReturned);

その後、この情報をttXlaTableCheckに渡して、レコードを別のデータ・ストアに安全に適用できるかどうかを確認します。

/* check compatibility */

    if (bStatus)

    {

      rc = ttXlaTableCheck (hXlaTarget,

        &tblVerDescSource.tblDesc, colDescSource,

        &iCompatible);