📄 cc_rcv_gh.pc
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File name : Cc_Rcv_GH.pc *
* Module ID : *
* Module Name : *
* Purpose : Get GH Message From MQ And Insert into DB *
* Author : Liu Yan Qiu (DIMPT) *
* Date Created : 1999,10,27 *
* Version : Version 1.0 *
* Environment : HP UNIX *
* Portability : UNIX Platform *
* Warnings : *
* References : *
* Calling Syntax : *
* Parameters : None *
* Returns : void *
* Calling Function : *
* Called Functions : When system startup *
* Datastores and usages : *
* (a) Input *
* (b) OutPut *
* Report : None *
* Screens : None *
* Messages Files : None *
* Change Log : *
* Change No. Date Author Reason For Change *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "/usr/bkfx/include/Cc_Rcv_GH/Cc_Rcv_GH.h"
void main()
{
signal(SIGTERM,Free_Mem);
EXEC SQL INCLUDE SQLCA;
rtn_code=InitRcvGH();
if ( rtn_code < 0 )
{
ProcessError(LOG_ERROR,"Calling Function InitRcvGH() Failed!");
exit(-1);
}
rtn_code = CCRcvGH();
if ( rtn_code < 0 )
{
ProcessError(LOG_ERROR,"Calling Function CCRcvGH() Failed!");
exit(-1);
}
rtn_code = EndRcvGHMsg();
if ( rtn_code < 0 )
{
ProcessError(LOG_ERROR,"Calling Function EndRcvGHMsg() Failed!");
exit(-1);
}
}
int InitRcvGH()
{
char *PID = "Cc_Rcv_GH.x Process(Port 110)";
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR userid[20];
VARCHAR password[20];
VARCHAR db_server[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL INCLUDE SQLCA;
EXEC SQL WHENEVER SQLERROR GOTO sqlerror;
strcpy( userid.arr,"bkdba");
userid.len = strlen (userid.arr);
strcpy( password.arr,"dba");
password.len = strlen( password.arr);
strcpy( db_server.arr,"mn1");
db_server.len = strlen (db_server.arr);
EXEC SQL CONNECT :userid IDENTIFIED BY :password using :db_server;
rtn_code = InitErrLogObj(PID, 2);
if ( rtn_code < 0 )
{
printf("Calling Function InitErrLogObj() Failed!");
}
interval = GetTimeInterval("CC_RCV_GH");
rtn_code = MQBKInit("GL");
#ifdef DEBUG
printf("interval is %d\n",interval);
printf("init code is %d\n",rtn_code);
#endif
if (rtn_code != 0)
{
ProcessError(LOG_ERROR,"Calling Function MQBKInit() Failed!");
return(-1);
}
return(0);
sqlerror:
ProcessError(LOG_ERROR,"Connect To DataBase SQL Error!");
CloseErrLogObj();
EXEC SQL RollBack;
return(-1);
}
int CCRcvGH()
{
while (1)
{
rtn_code = ReadGHMsg();
if ( rtn_code == -2 ) /* no message arrived */
{
sleep( interval );
}
else if ( rtn_code == -3 ) /* received an error message */
{
ProcessError(LOG_ERROR,"Can't Get Correct Message From GL\
MQ! Now Skip The Current Message And Try To Read Next One!");
}
else
{
if ( (( data_type[0] == 'G' ) && ( data_type[1] == 'H' )) || \
(( data_type[0] == 'J' ) && ( data_type[1] == 'H')) || \
(( data_type[0] == 'B' ) && ( data_type[1] == 'T')) )
{
rtn_code = CreateGHRcvLogStatus();
if ( rtn_code < 0 ) return(-1);
rtn_code = InsertRcvGHRec();
if ( rtn_code < 0 ) return(-1);
rtn_code = UpdateGHRcvLogStatus();
if ( rtn_code < 0 ) return(-1);
}
else if ( ( data_type[0] == 'C' ) && ( data_type[1] == 'A' ) && \
( data_type[2] == 'N' ) ) /* data_type is CANCEL */
{
rtn_code = Cancel_UpdateJSRZAndZFRZ();
if ( rtn_code < 0 ) return(-1);
rtn_code = Cancel_UpdateZFDZAndSendMQ();
if ( rtn_code < 0 ) return(-1);
}
free(data_type);
}
}
return(1);
}
int EndRcvGHMsg()
{
EXEC SQL WHENEVER SQLERROR GOTO sqlerror;
EXEC SQL COMMIT WORK RELEASE;
CloseErrLogObj();
MQBKClear();
return(1);
sqlerror:
ProcessError(LOG_ERROR,"Can't Commit DataBase In Function EndRcvGHMsg()!");
CloseErrLogObj();
MQBKClear();
EXEC SQL RollBack RELEASE;
return(-1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -