📄 pcs_snd_yx_p.pc
字号:
/*******************************************************************************
* File Name : PcsSndYXP.pc *
* Module ID : MD_P15_01 *
* Module Name : PcsSndYXP.pc *
* call PcsSndYX2() send msg to MQ*
* Auther : Gao Lin Li *
* Date Created : 07/22/1999 *
* Version : Version 1.0 *
* Environment : OSF1 Compaq V4.0 (Alpha) *
* Portability : Unix platform *
* Warnings : *
* References : *
* Calling Syntax : *
* Parameters : *
* Returns : integer *
* 0 success *
* -1 failure *
* Calling Functions : *
* InitPcsSndYXP() *
* EndPcsSndYXP() *
* PcsSndYX2() *
* Called Functions : Pcs_Start *
* Data Stores and Usages : *
* (a) Input : T_FSRZ,T_HZ,T_FSYXSJ,T_ZCFSSJ *
* (b) Output : MQ YX Message *
* Report : none *
* Screens : none *
* Message Files : none *
* *
* Change Log : *
* Change No. Date Auther Reason for Change *
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
EXEC SQL INCLUDE SQLCA;
#include <fcntl.h>
#include <signal.h>
#include "/usr/bkfx/include/myapi.h"
#include "/usr/bkfx/include/Pcs_Snd_YX_P/Pcs_Snd_YX_P.h"
#include "/usr/bkfx/include/Pcs_Snd_YX_P/cmYXStr.h"
#include "/usr/bkfx/include/Pcs_Snd_YX_P/cmdef.h"
int freect()
{
if( mheader!=NULL )
free(mheader);
EXEC SQL ROLLBACK WORK RELEASE;
exit(0);
}
/* Usage : PcsSndYXP.x */
main()
{
int coun=0;
int flag;
int retcode=0;
char produce_err_str[20];
char *PID = "Client Txn Clt_Mpt Process(Port 7111)";
int iTime;
ERROR=0;
i=0;
signal(SIGTERM,freect);
ProcessError(LOG_NORMAL,"PCS_Snd_YX_P: this is NORMAL message", END);
flag=InitPcsSndYXP();
if( flag!=0 )
{
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: error cannot connect database",END);
exit(0);
}
EXEC SQL SELECT bsbh INTO :snd_city FROM T_BSBH;
if( snd_city[0]=='\0'||snd_city[1]=='\0' )
{
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: bsbh in t_bsbh is NULL",END);
exit(0);
}
else
snd_city[2]='\0';
iTime=GetTimeInterval("PCS_SND_YX_P");
begin:
i=0;
ERROR=0;
datatype = SJFL_YX;
status = FSRZ_WAITFOR_SND;
EXEC SQL SELECT COUNT(*) INTO :coun FROM t_fsrz
WHERE sjfl=:datatype AND sjzt=:status;
if (coun == 0)
{
goto End;
}
EXEC SQL DECLARE c CURSOR FOR
SELECT fsxh FROM t_fsrz
WHERE sjfl = :datatype AND sjzt = :status;
flag=MQBKInit("YX");
if( flag<0 )
{
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: error when init mq yx",END);
goto End;
}
/* Get message length and memory of m_header */
len_msg = LEN_KEY + sizeof(snd_city)*2 + sizeof(fi_no) +sizeof(subtype)
+ ZH_LEN*2 + LEN_YX_REC + 10;
if ((mheader = (char *)malloc(len_msg+MID_LEN)) == NULL)
{
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: error there is no space in memory",END);
goto End;
}
EXEC SQL OPEN c;
while ( ++i <= coun )
{
EXEC SQL WHENEVER NOT FOUND DO break;
EXEC SQL FETCH c INTO : serial_no;
status = FSRZ_SENDED;
/* Update T_FSRZ status to SENDED */
UpdateSndLogStatus(serial_no,status);
status = HZ_SENDED;
flag=PcsSndYX2(serial_no,len_msg);
if( flag!=0 )
{
sprintf(produce_err_str,"%10d",serial_no);
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: error when send yxsj to queue fsxh is: ",produce_err_str);
EXEC SQL ROLLBACK WORK;
continue;
}
/* Delete these T_ZCFSSJ records */
EXEC SQL DELETE FROM t_zcfssj WHERE fsxh = :serial_no;
EXEC SQL COMMIT WORK;
}
EXEC SQL CLOSE c;
free(mheader);
End:
flag=MQBKClear();
if( flag<0 )
{
ProcessError(LOG_ERROR,"PCS_Snd_YX_P: error when mq bk clear",END);
}
#ifdef DEBUG
exit(0);
#endif
sleep(iTime);
goto begin;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -