磁带事务批处理

transaction_batch(infile, instruction_file, outfile):
	fread(infile, rec)					# 文件到结尾时, 什么也不做
	fread(instruction_file, ins)
	while !feof(infile) or !feof(instruction_file):
		if rec.key < ins.key:		# 直接复制
			fwrite(outfile, rec)
			fread(infile, rec)
		elif ins.type == INSERT and rec.key > ins.key:
			fwrite(outfile, new_record(ins))
			fread(instruction_file, ins)
		elif ins.type == DELETE and rec.key == ins.key:
			fread(infile, rec)
			fread(instruction_file, ins)
		elif ins.type == UPDATE and rec.key == ins.key:
			fwrite(outfile, update_record(rec, ins))
			fread(infile, rec)
			fread(instruction_file, ins)
		else:
			error()