_Rcommit ()- 落实当前记录
格式
#include <recio.h>
int _Rcommit(char *cmtid);语言级别
ILE C 扩展
线程安全
False
作业 CCSID 接口
发送到此函数的所有字符数据都应该使用作业的 CCSID。 此函数返回的所有字符数据都使用作业的 CCSID。 请参阅 了解 CCSID 和语言环境 以获取更多信息。
描述
_Rcommit() 函数完成调用该函数的作业的当前事务,并建立新的落实边界。 自上次落实边界以来所做的所有更改都是永久的。 在作业中的落实控制下打开的任何文件或资源都会受到影响。
cmtid 参数是一个以 null 结束的 C 字符串,用于标识与落实边界关联的更改组。 不能超过 4000 字节。
_Rcommit() 函数适用于数据库和 DDM 文件。
返回值
如果操作成功,那么 _Rcommit() 函数返回 1; 如果操作失败,那么返回零。 errno 的值可以设置为 EIOERROR (发生不可恢复的 I/O 错误) 或 EIORECERR (发生可恢复的 I/O 错误)。
示例
#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 );
}