📄 yxpapi.c
字号:
/* Result Sets Interface */
#ifndef SQL_CRSR
# define SQL_CRSR
struct sql_cursor
{
unsigned int curocn;
void *ptr1;
void *ptr2;
unsigned long magic;
};
typedef struct sql_cursor sql_cursor;
typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */
/* Thread Safety */
typedef void * sql_context;
typedef void * SQL_CONTEXT;
/* File name & Package Name */
struct sqlcxp
{
unsigned short fillen;
char filnam[10];
};
static struct sqlcxp sqlfpn =
{
9,
"yxpapi.pc"
};
static unsigned long sqlctx = 43523;
static struct sqlexd {
unsigned int sqlvsn;
unsigned int arrsiz;
unsigned int iters;
unsigned int offset;
unsigned short selerr;
unsigned short sqlety;
unsigned int unused;
short *cud;
unsigned char *sqlest;
char *stmt;
unsigned char **sqphsv;
unsigned int *sqphsl;
short **sqpind;
unsigned int *sqparm;
unsigned int **sqparc;
unsigned char *sqhstv[3];
unsigned int sqhstl[3];
short *sqindv[3];
unsigned int sqharm[3];
unsigned int *sqharc[3];
} sqlstm = {8,3};
/* Prototypes */
extern sqlcxt (/*_ void **, unsigned long *,
struct sqlexd *, struct sqlcxp * _*/);
extern sqlcx2t(/*_ void **, unsigned long *,
struct sqlexd *, struct sqlcxp * _*/);
extern sqlbuft(/*_ void **, char * _*/);
extern sqlgs2t(/*_ void **, char * _*/);
extern sqlorat(/*_ void **, unsigned long *, void * _*/);
/* Forms Interface */
static int IAPSUCC = 0;
static int IAPFAIL = 1403;
static int IAPFTL = 535;
extern void sqliem(/*_ char *, int * _*/);
static char *sq0008 =
"select zh ,zzh ,zcfssj from t_zcfssj where fsxh=:b0 order by zh ";
typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;
typedef struct { unsigned short len; unsigned char arr[1]; } varchar;
/* cud (compilation unit data) array */
static short sqlcud0[] =
{8,4130,
2,0,0,1,42,0,5,97,0,2,2,0,1,0,1,1,0,0,1,3,0,0,
24,0,0,2,71,0,5,106,0,3,3,0,1,0,1,1,0,0,1,3,0,0,1,97,0,0,
50,0,0,3,0,0,31,133,0,0,0,0,1,0,
64,0,0,4,0,0,31,136,0,0,0,0,1,0,
78,0,0,5,0,0,27,242,0,3,3,0,1,0,1,9,0,0,1,9,0,0,1,10,0,0,
104,0,0,6,0,0,30,303,0,0,0,0,1,0,
118,0,0,7,60,0,4,313,0,3,1,0,1,0,2,5,0,0,2,5,0,0,1,3,0,0,
144,0,0,8,76,0,9,363,0,1,1,0,1,0,1,3,0,0,
162,0,0,8,0,0,13,367,0,3,0,0,1,0,2,3,0,0,2,3,0,0,2,9,0,0,
188,0,0,8,0,0,15,371,0,0,0,0,1,0,
202,0,0,8,0,0,15,382,0,0,0,0,1,0,
216,0,0,9,0,0,31,397,0,0,0,0,1,0,
230,0,0,10,0,0,31,408,0,0,0,0,1,0,
244,0,0,8,0,0,15,424,0,0,0,0,1,0,
};
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* EXEC SQL INCLUDE SQLCA;
*/
/*
* $Header: sqlca.h,v 1.3 1994/12/12 19:27:27 jbasu Exp $ sqlca.h
*/
/* Copyright (c) 1985,1986 by Oracle Corporation. */
/*
NAME
SQLCA : SQL Communications Area.
FUNCTION
Contains no code. Oracle fills in the SQLCA with status info
during the execution of a SQL stmt.
NOTES
**************************************************************
*** ***
*** This file is SOSD. Porters must change the data types ***
*** appropriately on their platform. See notes/pcport.doc ***
*** for more information. ***
*** ***
**************************************************************
If the symbol SQLCA_STORAGE_CLASS is defined, then the SQLCA
will be defined to have this storage class. For example:
#define SQLCA_STORAGE_CLASS extern
will define the SQLCA as an extern.
If the symbol SQLCA_INIT is defined, then the SQLCA will be
statically initialized. Although this is not necessary in order
to use the SQLCA, it is a good pgming practice not to have
unitialized variables. However, some C compilers/OS's don't
allow automatic variables to be init'd in this manner. Therefore,
if you are INCLUDE'ing the SQLCA in a place where it would be
an automatic AND your C compiler/OS doesn't allow this style
of initialization, then SQLCA_INIT should be left undefined --
all others can define SQLCA_INIT if they wish.
If the symbol SQLCA_NONE is defined, then the SQLCA variable will
not be defined at all. The symbol SQLCA_NONE should not be defined
in source modules that have embedded SQL. However, source modules
that have no embedded SQL, but need to manipulate a sqlca struct
passed in as a parameter, can set the SQLCA_NONE symbol to avoid
creation of an extraneous sqlca variable.
MODIFIED
jbasu 12/12/94 - Bug 217878: note this is an SOSD file
losborne 08/11/92 - No sqlca var if SQLCA_NONE macro set
Clare 12/06/84 - Ch SQLCA to not be an extern.
Clare 10/21/85 - Add initialization.
Bradbury 01/05/86 - Only initialize when SQLCA_INIT set
Clare 06/12/86 - Add SQLCA_STORAGE_CLASS option.
*/
#ifndef SQLCA
#define SQLCA 1
struct sqlca
{
/* ub1 */ char sqlcaid[8];
/* b4 */ long sqlabc;
/* b4 */ long sqlcode;
struct
{
/* ub2 */ unsigned short sqlerrml;
/* ub1 */ char sqlerrmc[70];
} sqlerrm;
/* ub1 */ char sqlerrp[8];
/* b4 */ long sqlerrd[6];
/* ub1 */ char sqlwarn[8];
/* ub1 */ char sqlext[8];
};
#ifndef SQLCA_NONE
#ifdef SQLCA_STORAGE_CLASS
SQLCA_STORAGE_CLASS struct sqlca sqlca
#else
struct sqlca sqlca
#endif
#ifdef SQLCA_INIT
= {
{'S', 'Q', 'L', 'C', 'A', ' ', ' ', ' '},
sizeof(struct sqlca),
0,
{ 0, {0}},
{'N', 'O', 'T', ' ', 'S', 'E', 'T', ' '},
{0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
}
#endif
;
#endif
#endif
/* end 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"
void ProcessError( char *LOG, char *sErrorMessage1, char *sErrorMessage2 )
{
FILE* hErrorFile;
char cDateTime[100],tempstr[100];
int i,j,len,n;
long filesize;
char bakfile[100];
tempstr[0]='\0';
len=strlen(sErrorMessage1);
for(i=0;i<=len;i++)
{
if(sErrorMessage1[i]=='%')
{
n=i;
if(len!=i+1)
{
for(j=0;j<200&&sErrorMessage1[i+2]!='\0';j++,i++)
tempstr[j]=sErrorMessage1[i+2];
tempstr[j]='\0';
}
break;
}
if(sErrorMessage1[i]=='\0')
{
n=i;
tempstr[0] = '\0';
break;
}
}
printf("\n%s",LOG);
printf("%s",sErrorMessage1);
printf("%s",sErrorMessage2);
printf("%s\n",tempstr);
sErrorMessage1[n]='\0';
hErrorFile = fopen( ERROR_LOG_FILE, "a" );
if( hErrorFile == NULL )
{
printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
return;
}
fseek( hErrorFile, 0 ,SEEK_END );
filesize = ftell(hErrorFile);
if (filesize > 5242880/5)
{
fclose(hErrorFile );
sprintf(bakfile, "mv %s %s.bak", ERROR_LOG_FILE, ERROR_LOG_FILE);
system(bakfile);
hErrorFile = fopen( ERROR_LOG_FILE, "a" );
if( hErrorFile == NULL )
{
printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
return;
}
}
fseek( hErrorFile, 0 ,SEEK_END );
fputs( "\n",hErrorFile);
fputs( LOG ,hErrorFile);
fputs( sErrorMessage1,hErrorFile );
fputs( sErrorMessage2,hErrorFile );
fputs( tempstr,hErrorFile );
fputs( "\n",hErrorFile);
fclose( hErrorFile );
sprintf( cDateTime, "date >> %s\n", ERROR_LOG_FILE );
system( cDateTime );
system( "date");
}
void PutintoF(char *string )
{
FILE *fp;
fp=fopen("checkfile.txt","w");
fputs(string,fp);
fclose(fp);
}
int UpdateSndLogStatus(long serial_no,
char status)
{
/* EXEC SQL WHENEVER SQLERROR DO sqlerror(); */
/* SQL error handling */
/* EXEC SQL UPDATE t_fsrz SET sjzt = :status
WHERE fsxh = :serial_no; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 2;
sqlstm.stmt = "update t_fsrz set sjzt=:b0 where fsxh=:b1";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )2;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlstm.sqhstv[0] = (unsigned char *)&status;
sqlstm.sqhstl[0] = (unsigned int )1;
sqlstm.sqindv[0] = ( short *)0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqhstv[1] = (unsigned char *)&serial_no;
sqlstm.sqhstl[1] = (unsigned int )4;
sqlstm.sqindv[1] = ( short *)0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
if (sqlca.sqlcode < 0) sqlerror();
}
return(0);
}
int UpdateHZStatus(long serial_no,char *rcv_province_code,
char status)
{
/* EXEC SQL WHENEVER SQLERROR DO sqlerror(); */
/* SQL error handling */
/* EXEC SQL UPDATE t_hz SET hzzt = :status, hzjssj = SYSDATE
WHERE fsxh = :serial_no AND sjbh = :rcv_province_code; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 3;
sqlstm.stmt = "update t_hz set hzzt=:b0,hzjssj=sysdate where (fsxh=:b1\
and sjbh=:b2)";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )24;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlstm.sqhstv[0] = (unsigned char *)&status;
sqlstm.sqhstl[0] = (unsigned int )1;
sqlstm.sqindv[0] = ( short *)0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqhstv[1] = (unsigned char *)&serial_no;
sqlstm.sqhstl[1] = (unsigned int )4;
sqlstm.sqindv[1] = ( short *)0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqhstv[2] = (unsigned char *)rcv_province_code;
sqlstm.sqhstl[2] = (unsigned int )0;
sqlstm.sqindv[2] = ( short *)0;
sqlstm.sqharm[2] = (unsigned int )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
if (sqlca.sqlcode < 0) sqlerror();
}
return(0);
}
void sqlerror()
{
char tempstring[200];
char ERR_CODE[10];
int init_time=0;
ERROR=1;
/* EXEC SQL WHENEVER sqlerror continue; */
ProcessError( LOG_ERROR, "PCS_SND_YXP: ",sqlca.sqlerrm.sqlerrmc );
strncpy(ERR_CODE,sqlca.sqlerrm.sqlerrmc,9);
ERR_CODE[9]='\0';
if( strcmp(ERR_CODE,"ORA-03127")==0|| strcmp(ERR_CODE,"ORA-03114")==0|| strcmp(ERR_CODE,"ORA-03123")==0|| strcmp(ERR_CODE,"ORA-01034")==0|| strcmp(ERR_CODE,"ORA-01089")==0||strcmp(ERR_CODE,"ORA-01012")==0||strcmp(ERR_CODE,"ORA-01089") ==0||strcmp( ERR_CODE, "ORA-01033") ==0 )
{
sleep(INIT_INTERVAL);
init_time++;
if (init_time == 6)
{
ProcessError(LOG_NORMAL, "PCS_SND_YXP: Could not connect to the database, so exit now!",END);
freect(0);
exit(0);
}
InitPcsSndYXP();
/* EXEC SQL ROLLBACK WORK; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 3;
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )50;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}
return;
}
/* EXEC SQL ROLLBACK WORK; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 3;
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )64;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}
return;
}
/*Get the Time_Interval specified in the file and return it */
int GetTimeInterval(char* cType)
{
FILE *hTimeInterval;
char cLine[MAX_LINE_LEN+1], cCaption[100], cValue[21];
int iInterval, i;
char* pLine;
hTimeInterval = fopen( CONFIG_FILE_FOR_TIMEINTERVAL, "r" );
if( hTimeInterval == NULL )
{
ProcessError(LOG_ERROR, "GetTimeInterval: this is message:Cannot open file", CONFIG_FILE_FOR_TIMEINTERVAL);
return(DEFAULT_TIMEINTERVAL);
}
while( myapi_ReadALine( cLine, hTimeInterval ) )
{
if( cLine[0] == '#' ) continue;
if( cLine[0] == NULL ) continue;
pLine = cLine;
while( (*pLine == ' ') || (*pLine == '\t') ) pLine++;
i=0;
while( (*pLine != ' ') && (*pLine != '\t') && (*pLine != '\0') )
{
cCaption[i] = *pLine;
i++;
pLine++;
}
cCaption[i] = '\0';
if( strcmp( cCaption, cType ) == 0 ) /*Match*/
{
while( (*pLine == ' ') || (*pLine == '\t') ) pLine++;
if( *pLine == '\0' )
{
fclose(hTimeInterval);
return(DEFAULT_TIMEINTERVAL);
}
i=0;
while( (*pLine != ' ') && (*pLine != '\t') && (*pLine != '\0') )
{
cValue[i] = *pLine;
i++;
pLine++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -