_Rrollbck () -回復確定控制變更
格式
#include <recio.h>
int _Rrollbck(void);語言層次
ILE C 延伸
安全執行緒
否
說明
_Rrollbck() 函數會將最後一個確定界限重新建立為現行確定界限。 在工作中的確定控制下對檔案所做的所有變更都會反轉。 會釋放所有已鎖定的記錄。 在工作中的確定控制下開啟的任何檔案都會受到影響。 當檔案開啟為在確定控制下時,您必須指定關鍵字參數 commit=y。 在此之前必須已設定確定控制環境。
_Rrollbck() 函數對資料庫及 DDM 檔案有效。
回覆值
範例
#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 );
}相關資訊
- _Rcommit ()-確定現行記錄
- 回復系統 手冊