2017-08-03 73 views
1

我在Oracle Golden Gate中有create custom User Exit问题。 我需要连接到数据库复制期间的更改流,并创建此更改的JSON字符串。Oracle Golden Gate用户退出 - EXIT_CALL_PROCESS_RECORD未通过

在这一刻我已经从甲骨文12C到12C甲骨文一种完全可行的数据库复制,我创建了一个发送到由金门提取sended日志事件一个简单的库。

一切正常,到了这一刻,我需要赶上EXIT_CALL_PROCESS_RECORD,因为这种类型的事件包含表名,列和数据(Exit Call Types) 但由于某些原因,此事件不会出现在报告文件我只有三种类型事件:

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 [email protected]: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:

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; 
} 

回答

0

代码本身似乎是正确的。如果你用C而不是C++编译相同的代码 - 它能正常工作。您必须向Oracle提交SR请求 - 这可能是一个错误。

#include <stdio.h> 

    #if defined(__linux__) 
    #include <stdint.h> 
    #include <stdarg.h> 
    #define I64_FMT "%Ld" 
    #endif 

    #if defined(__MVS__) 
    #include <stdarg.h> 
    #include <varargs.h> 
    #include <inttypes.h> 
    #define I64_FMT "%lld" 
    #endif 

    #if !defined(__MVS__) && !defined(__linux__) 
    #include <stdarg.h> 
    #define I64_FMT "%lld" 
    #endif 

    #include <string.h> 
    #include <sys/types.h> 
    #include <stdlib.h> 
    #include <ctype.h> 

#include "usrdecs.h" 

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; 
} 
+0

在C编译后,一切都很好,非常感谢。 –