create custom User Exit
我在 Oracle Golden Gate有问题。我需要在数据库复制期间连接到更改流并创建此更改的 JSON 字符串。
此刻,我有一个从 Oracle 12c 到 Oracle 12c 的完全正常工作的数据库复制,我创建了一个简单的库,该库将发送到 GoldenGate 提取发送的日志事件。
到目前为止一切正常,我需要捕捉EXIT_CALL_PROCESS_RECORD
,因为这种类型的事件包含表名、列和数据(退出调用类型)但是由于某种原因,这个事件没有出现,在报告文件中我只有三种类型的事件:
EXIT_CALL_CHECKPOINT
EXIT_CALL_BEGIN_TRANS
EXIT_CALL_END_TRANS
我如何调用EXIT_CALL_PROCESS_RECORD
调用类型?
这是我当前的配置和退出用户源代码:
数据挖掘者:
EXTRACT REXT1
EXTTRAIL ./dirdat/Z1
TRANLOGOPTIONS DBLOGREADER
GETUPDATEBEFORES
FETCHOPTIONS FETCHPKUPDATECOLS
USERID GGUSER@192.168.99.100:32774/xe , PASSWORD GGUSER
TABLE ERP.*;
数据泵:
EXTRACT REXT2
DISCARDFILE ./dirrpt/eqalap.dsc, PURGE
RMTHOST 127.0.0.1, MGRPORT 7851, COMPRESS
RMTTRAIL ./dirdat/Z2
CUSEREXIT hello.so CUSEREXIT, INCLUDEUPDATEBEFORES
NOPASSTHRU
MAP ERP.*, TARGET HRMS.*;
复制:
replicat RREP1
setenv (NLS_LANG = AMERICAN_AMERICA.WE8MSWIN1252)
useridalias GGTARGETADMIN domain OGG
handlecollisions
assumetargetdefs
CUSEREXIT hello.so CUSEREXIT, INCLUDEUPDATEBEFORES
map HRMS.* target HRMS.* ;
用户退出源代码:
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdint.h>
#include <ctype.h>
#include "usrdecs.h"
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
extern "C" {
void ERCALLBACK(ercallback_function_codes function_code, void *buf, short *presult_code);
void call_callback(ercallback_function_codes function_code, void *buf, short *result_code);
void output_msg(char *msg, ...);
void CUSEREXIT(exit_call_type_def exit_call_type, exit_result_def *exit_call_result, exit_params_def *exit_params);
}
void ERCALLBACK(ercallback_function_codes function_code, void *buf, short *presult_code);
void call_callback(ercallback_function_codes function_code, void *buf, short *result_code);
void CUSEREXIT(exit_call_type_def exit_call_type, exit_result_def *exit_call_result, exit_params_def *exit_params);
void call_callback(ercallback_function_codes function_code, void *buf, short *result_code) {
ERCALLBACK(function_code, buf, result_code);
}
void output_msg(char *msg, ...) {
short result_code;
char temp_msg[1000];
va_list args;
vsprintf(temp_msg, msg, args);
call_callback(OUTPUT_MESSAGE_TO_REPORT, temp_msg, &result_code);
}
void CUSEREXIT(exit_call_type_def exit_call_type, exit_result_def *exit_call_result, exit_params_def *exit_params) {
short result_code;
switch (exit_call_type) {
case EXIT_CALL_START:
output_msg((char*)"EXIT_CALL_START\n", result_code);
break;
case EXIT_CALL_BEGIN_TRANS:
output_msg((char*)"EXIT_CALL_BEGIN_TRANS\n", result_code);
break;
case EXIT_CALL_PROCESS_RECORD:
output_msg((char*)"EXIT_CALL_PROCESS_RECORD\n", result_code);
break;
case EXIT_CALL_DISCARD_ASCII_RECORD:
output_msg((char*)"EXIT_CALL_DISCARD_ASCII_RECORD\n", result_code);
break;
case EXIT_CALL_DISCARD_RECORD:
output_msg((char*)"EXIT_CALL_DISCARD_RECORD\n", result_code);
break;
case EXIT_CALL_END_TRANS:
output_msg((char*)"EXIT_CALL_END_TRANS\n", result_code);
break;
case EXIT_CALL_CHECKPOINT:
output_msg((char*)"EXIT_CALL_CHECKPOINT\n", result_code);
break;
case EXIT_CALL_PROCESS_MARKER:
output_msg((char*)"EXIT_CALL_PROCESS_MARKER\n", result_code);
break;
case EXIT_CALL_STOP:
output_msg((char*)"EXIT_CALL_STOP\n", result_code);
break;
case EXIT_CALL_DISCARD_TRANS_RECORD:
output_msg((char*)"EXIT_CALL_DISCARD_TRANS_RECORD\n", result_code);
break;
case EXIT_CALL_ABORT_TRANS:
output_msg((char*)"EXIT_CALL_ABORT_TRANS\n", result_code);
break;
case EXIT_CALL_EVENT_RECORD:
output_msg((char*)"EXIT_CALL_EVENT_RECORD\n", result_code);
break;
case EXIT_CALL_FATAL_ERROR:
output_msg((char*)"EXIT_CALL_FATAL_ERROR\n", result_code);
break;
default:
output_msg((char*)"default\n", result_code);
break;
}
*exit_call_result = EXIT_OK_VAL;
}