_Rrollbck () -コミットメント制御の変更のロールバック

形式

#include <recio.h>

int _Rrollbck(void);

言語レベル

ILE C Extension

スレッド・セーフ

いいえ

説明

_Rrollbck() 関数は、最後のコミットメント境界を現行のコミットメント境界として再設定します。 ジョブ内のコミットメント制御下でファイルに加えられた変更は、すべて反転されます。 ロック・レコードはすべて解除されます。 ジョブ内のコミットメント制御の下でオープンしているファイルが影響を受けます。 ファイルがコミットメント制御されるようにオープンしている場合は、キーワード・パラメーターを commit=y を指定する必要があります。 コミットメント制御環境は、この前にすでにセットアップされていなければなりません。

_Rrollbck() 関数は、データベースおよび DDM ファイルに対して有効です。

戻り値

_Rrollbck() 関数は、操作が成功した場合は 1 を返し、操作が失敗した場合はゼロを返します。 errno の値は、EIOERROR (リカバリー不能な入出力エラーの発生) または EIORECERR (リカバリー可能な入出力エラーの発生) に設定されます。 errnoの設定については、 表1 および表1を参照のこと。

#include <stdio.h>
#include <recio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void)
{
  char       buf[40];
  int        rc = 1;
  _RFILE     *purf;
  _RFILE     *dailyf;
 
  /* Open purchase display file and daily transaction file          */
  if ( ( purf = _Ropen ( "MYLIB/T1677RD3", "ar+,indicators=y" )) == NULL )
  {
      printf ( "Display file did not open.\n" );
      exit ( 1 );
  }
 
  if ( ( dailyf = _Ropen ( "MYLIB/T1677RDA", "wr,commit=y") ) == NULL )
  {
      printf ( "Daily transaction file did not open.\n" );
      exit ( 2 );
  }
 
  /* Select purchase record format */
  _Rformat ( purf, "PURCHASE" );
 
  /* Invite user to enter a purchase transaction.                   */
  /* The _Rwrite function writes the purchase display.              */
  _Rwrite ( purf, "", 0 );
  _Rreadn ( purf, buf, sizeof(buf), __DFT );
 
  /* Update daily transaction file                                  */
  rc = (( _Rwrite ( dailyf, buf, sizeof(buf) ))->num_bytes );
 
  /* If the databases were updated, then commit the transaction.    */
  /* Otherwise, rollback the transaction and indicate to the        */
  /* user that an error has occurred and end the application.       */
  if ( rc )
    {
        _Rcommit ( "Transaction complete" );
    }
  else
    {
        _Rrollbck ( );
        _Rformat ( purf, "ERROR" );
    }
 
  _Rclose ( purf );
  _Rclose ( dailyf );
}

関連情報