⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 convapi.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
📖 第 1 页 / 共 4 页
字号:
	EXEC SQL WHENEVER SQLERROR DO sqlerror();

	

	EXEC SQL CONNECT :username IDENTIFIED BY :password;

	if( ERROR!=0 )

	{

		ERROR=0;

		return(-1);

	}

	return(0);

}



void ErrorEnded(char *string)

{

	ProcessError(LOG_ERROR,string,END);

	if(message!=NULL)

	free(message);

	if(messagesj!=NULL)

	free(messagesj);

	if(messagepd!=NULL)

	free(messagepd);

	if(messagepdsj!=NULL)

	free(messagepdsj);

	EXEC SQL ROLLBACK WORK;

}



/*add null at left or right to format a string, 0 means left ,1 means right*/



void str_givenlen( char *string,int p,char location )

{

	int i,j;

	char nullstr[]="               ";

	char tmpstr[20];

	trim(string);

	tmpstr[0]='\0';

	for(;;)

	{

		if( (string[0]=='0') && (strlen(string)!=1)&& (string[1]!='.') )

			string[0]=' ';

		else break;

		

		trim(string);

	}

	

	i=strlen(string);

	if( location=='0' )	/* 0 means left */

	{

		strncpy(tmpstr,nullstr,p-i);

		tmpstr[p-i]='\0';

		strcat(tmpstr,string);

		

		strcpy(string,tmpstr);

	}

	else

	{

		strncat(string,nullstr,p-i);

		string[p]='\0';

	}

}



/*  Check wether a file is exist  */

int MyExistFile( const char* sFile )

{

	FILE *hFileToOpen;

	hFileToOpen = fopen( sFile, "r" );

	if( hFileToOpen != (FILE*)NULL )

	{

		fclose( hFileToOpen );

		return(1);

	}

	else

		return(0);

}



int strnum_format(char *tempstr)

{

	if( tempstr[1]==' ' )

		return(-1);

	trim(tempstr);

	if( strlen(tempstr)==1 )

	{

		tempstr[2]='\0';

		tempstr[1]=tempstr[0];

		tempstr[0]='0';

	}

	if( strlen(tempstr)==0||strlen(tempstr)>2 )

		return(-1);

	return(0);

}



int strformat(char *tempstr)

{

	int    old,new,count;

	char  test_str[MID_LEN],tempstring[MID_LEN];

	strcpy(test_str,tempstr);

	trim(test_str);

	old=strlen(tempstr);

	new=strlen(test_str);

	count=old-new;

	tempstring[0]='\0';

	for( ;count>0;count-- )

		strcat(tempstring,"0");

	strcat(tempstring,test_str);

	strcpy(tempstr,tempstring);

	return(0);

}



int GetPATH(char *bkdh,char *sjbh,int yxnf,char fbkjbh[3])

{

/*	trim(bkdh);

*/	EXEC SQL WHENEVER SQLERROR DO sqlerror();

	EXEC SQL SELECT fbkjbh INTO :fbkjbh FROM t_snmlfb WHERE bkdh=:bkdh and yxnf=:yxnf;

	if( ERROR!=0 )

	{

		ERROR=0;

		return(-1);

	}

/*	trim(fbkjbh);

*/	return(0);

}



int ConvertZZYSSJ(char *tempstring,char *messagesj,long int key,char *sjbh,int yxnf)

{

	int num_yffs,control;

	char tempstr[SHORT_LEN];

	char zfj[9];
	

	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT COUNT(*) INTO :control FROM T_JSZDYSSJ

		 WHERE jsxh=:key and sjbh=:sjbh;

	

	EXEC SQL DECLARE cur_zzsj CURSOR FOR

		SELECT zfjbh FROM t_jszfjbnr,t_jszfjb WHERE t_jszfjbnr.sjbh=:sjbh AND t_jszfjb.nf=:yxnf 
			AND t_jszfjb.sjbh=t_jszfjbnr.sjbh and t_jszfjb.jsxh=t_jszfjbnr.jsxh 
			ORDER BY t_jszfjbnr.zfjxh;
	EXEC SQL OPEN cur_zzsj;

	messagesj[0]='\0';
	strcat(messagesj,tempstring);
	strcat(messagesj,"\n");
	while(control>0)

	{

		control--;

		EXEC SQL FETCH cur_zzsj INTO :zfj;

		trim(zfj);
		EXEC SQL SELECT yffs INTO :num_yffs FROM t_jszdyssj WHERE jsxh=:key and sjbh=:sjbh and zfjbh=:zfj;

		if( ERROR != 0 )
		{
			ERROR=0;
			ProcessError(LOG_ERROR,"PCS_CONVERT_FILE: error when get yffs! ",END);
			EXEC SQL CLOSE cur_zzsj;
			return(-1);
		}
		sprintf(messagesj,"%s%ld,",messagesj,num_yffs);
	}

	strcat(messagesj,"\n");

/*	printf("%s",messagesj);*/

	EXEC SQL CLOSE cur_zzsj;

	return(0);

}

int ConvertZJYSSJ(char *tempstring,char *messagesj,long int key,char *sjbh)

{

	int num_yffs,round_count,i;

	char zfjbh[SHORT_LEN];

	char tempstr[SHORT_LEN];

	

/*	strcpy(messagesj,tempstring);*/

	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT count(*) INTO :round_count FROM t_jszdyssj

		 WHERE jsxh=:key and sjbh=:sjbh;

	EXEC SQL DECLARE cur_zjsj CURSOR FOR

		SELECT yffs,zfjbh FROM t_jszdyssj WHERE jsxh=:key and sjbh=:sjbh;

	EXEC SQL OPEN cur_zjsj;

	messagesj[0]='\0';

	strcat(messagesj,tempstring);
	strcat(messagesj,"\n");
	for(i=0;i<round_count;i++)

	{

		EXEC SQL FETCH cur_zjsj INTO :num_yffs,:zfjbh;

		if( ERROR != 0 )
		{
			ERROR=0;
			ProcessError(LOG_ERROR,"PCS_CONVERT_FILE: error when get yffs! ",END);
			EXEC SQL CLOSE cur_zjsj;
			return(-1);
		}
		
		trim(zfjbh);

		sprintf(messagesj,"%s%s,%ld,",messagesj,zfjbh,num_yffs);
	}

	strcat(messagesj,"\n");

	EXEC SQL CLOSE cur_zjsj;

	return(0);

}



int CallConvertZDYS( long int Match_key,char *sjbh )

{

	char tempstr[MID_LEN];

	char tempstring[MID_LEN];

	char temp_bkdh[MID_LEN];

	char temp,tmp_jsfs;

	char jsfs[SHORT_LEN];

	char fbkjbh[3];

	char SJ_name[MID_LEN];

	char SJ_name_no[MID_LEN];

	char file_locat[MID_LEN];

	int  i, avoid_repeat;

	int  tempnum, retcode;

	struct stZDYSSMDBRec ZDSMDB;

	short dingj_id,dyzs_id,dyk_id,lszs_id,lsk_id;


	ERROR=0;

	EXEC SQL WHENEVER SQLERROR DO sqlerror();

	EXEC SQL SELECT * INTO 

		:ZDSMDB.yslx,:ZDSMDB.wjbh,:ZDSMDB.qdqa,:ZDSMDB.kq,:ZDSMDB.dingj :dingj_id,:ZDSMDB.dyzs :dyzs_id,

		:ZDSMDB.dyk :dyk_id,:ZDSMDB.lszs :lszs_id,:ZDSMDB.lsk :lsk_id,:ZDSMDB.sjbh,:ZDSMDB.bkdh,:ZDSMDB.yxnf,:ZDSMDB.jsxh 

		FROM t_jszdyssm WHERE jsxh=:Match_key AND sjbh=:sjbh;

	if( ERROR!=0 )

	{

		ERROR=0;

		return(-1);

	}

	temp=ZDSMDB.yslx[0];

	tempstr[0]='\0';

	trim(ZDSMDB.bkdh);


	GetPATH(ZDSMDB.bkdh,ZDSMDB.sjbh,ZDSMDB.yxnf,fbkjbh);

	EXEC SQL SELECT jsfs INTO :jsfs FROM t_fbkj WHERE fbkjbh=:fbkjbh;

	trim(jsfs);

	tmp_jsfs=jsfs[0];


/*** this is the clause to insert into temp table t_tempysflag ***/
	EXEC SQL SELECT COUNT(*) INTO :avoid_repeat FROM t_tempysflag WHERE jsxh=:Match_key AND sjbh=:sjbh;

	if ( avoid_repeat==0 )
		EXEC SQL INSERT INTO t_tempysflag VALUES ( :fbkjbh,:tmp_jsfs,:Match_key,:sjbh,sysdate );
/*** ***/

	if( (strcmp(jsfs,"0")!=0)&&(strcmp(jsfs,"3")!=0) )

	{

		

/*		UpdateJSRZ_cved(Match_key,sjbh);

*/		return(0);

	}

	message=(char *)malloc((YSSM_LEN+1)*sizeof(char));

	if( message==NULL )

	{

		ProcessError(LOG_ERROR,"PCS_Convert_File: error no space in memory when use function ","CallConvertZDYS");

		return(-1);

	}

	strcpy(tempstr,FBKJ_PATH);

	strcat(tempstr,fbkjbh);

	strcat(tempstr,"/bak/");

	strcpy(file_locat,tempstr);

	switch( temp )

	{

		case ZZ:	strcat(tempstr,"BZZY");

			break;

		case KZZ:	strcat(tempstr,"KZZY");

			break;

		case ZJ:	strcat(tempstr,"BZJY");

			break;

		case KZJ:	strcat(tempstr,"KZJY");

			break;

		default:	ErrorEnded("PCS_Convert_File: error in function CallConvertZDYS yslx is not in zdys");

				return(-1);

	}

	/* get zdys data filename */

/*	tempstring[0]='\0';

	strcat(tempstr,".");

	strcpy(tempstring,ZDSMDB.sjbh);

	trim(tempstring);

	strcat(tempstr,tempstring);

*/	h_zdys=fopen(tempstr,"a");

	if( h_zdys == NULL )

	{

		ProcessError(LOG_ERROR,"PCS_Convert_File: cannot open ",tempstr);

		createdir();
		free(message);

		return(-1);

	}

	fseek(h_zdys,0,SEEK_END);

	tempstr[0]='\0';

	str_givenlen( ZDSMDB.bkdh,6,RIGHT );

	strcpy(message,ZDSMDB.bkdh);

	strcat(message,BsbhFromT);

	strcat(message,ZDSMDB.sjbh);

	itoa(ZDSMDB.qdqa,tempstr,2);

	strcat(message,tempstr);

	strcat(message,"      ");

	strcat(message,ZDSMDB.kq);

	if(dingj_id==-1)

		strcat(message,"      ");

	else

	{

		ftoa(ZDSMDB.dingj,tempstr,2,7);

		str_givenlen(tempstr,6,LEFT);

		strcat(message,tempstr);

	}

	if(dyzs_id==-1)

		strcat(message,"          ");

	else

	{

		itoa(ZDSMDB.dyzs,tempstr,10);

		str_givenlen(tempstr,10,LEFT);

		strcat(message,tempstr);

	}

	if(dyk_id==-1)

		strcat(message,"           ");

	else

	{

		ftoa(ZDSMDB.dyk,tempstr,2,12);

		str_givenlen(tempstr,11,LEFT);

		strcat(message,tempstr);

	}

	tempstr[0]='\0';

	if(lszs_id==-1)

		strcat(message,"          ");

	else

	{

		itoa(ZDSMDB.lszs,tempstr,10);

		str_givenlen(tempstr,10,LEFT);

	

		strcat(message,tempstr);

	}

	tempstr[0]='\0';

	if(lsk_id==-1)

		strcat(message,"           ");

	else

	{

		ftoa(ZDSMDB.lsk,tempstr,2,12);

		str_givenlen(tempstr,11,LEFT);

		strcat(message,tempstr);

	}

	if( ((ZDSMDB.yxnf)%2)==1 )

		strcpy(tempstr,"1");

	else

		strcpy(tempstr,"0");

	strcat(message,tempstr);

	strcat(message,"\n");

	fputs(message,h_zdys);

	free(message);

	fclose(h_zdys);



	strcpy(temp_bkdh,ZDSMDB.bkdh);

	trim(temp_bkdh);

	

	if( temp=='1' || temp=='7' )
	{
		strcpy(tempstring,"ZZ");

		strcat(tempstring,temp_bkdh);

		strcat(tempstring,".");

		strcat(tempstring,ZDSMDB.sjbh);

	}
	else if ( temp=='2' || temp=='8' )
	{
		strcpy(tempstring,"ZJ");

		strcat(tempstring,temp_bkdh);

		strcat(tempstring,".");

		strcat(tempstring,ZDSMDB.sjbh);

	}

	if( temp=='1' )
	{
		strcpy(tempstr,"BZZ");
		YS_SINGAL[0]='1';
	}
	else if( temp=='7' )
	{
		strcpy(tempstr,"KZZ");
		YS_SINGAL[6]='1';
	}
	else if( temp=='2' )
	{
		strcpy(tempstr,"BZJ");
		YS_SINGAL[1]='1';
	}
	else if( temp=='8' )
	{
		strcpy(tempstr,"KZJ");
		YS_SINGAL[7]='1';
	}

	

	messagesj=(char *)malloc(MAX_YSSJ_LEN*sizeof(char));

	if( messagesj==NULL )

	{

		ProcessError(LOG_ERROR,"PCS_Convert_File: no space in memory when use ","CallConvertZDYS");

		return(-1);

	}

	messagesj[0]='\0';

	switch( temp )

	{

		case ZZ:	retcode=ConvertZZYSSJ(tempstring,messagesj,Match_key,ZDSMDB.sjbh,ZDSMDB.yxnf);

			break;

		case KZZ:	retcode=ConvertZZYSSJ(tempstring,messagesj,Match_key,ZDSMDB.sjbh,ZDSMDB.yxnf);

			break;

		case ZJ:	retcode=ConvertZJYSSJ(tempstring,messagesj,Match_key,ZDSMDB.sjbh);

				
			break;

		case KZJ:	retcode=ConvertZJYSSJ(tempstring,messagesj,Match_key,ZDSMDB.sjbh);

				
			break;

		default:	ErrorEnded("PCS_Convert_File: error in function CallConvertZDYS yslx is not in zdys");

				return(-1);

	}


	if( retcode!=0 )
	{
		ProcessError(LOG_ERROR,"PCS_CONVERT_FILE: error when convert yssj! ",END);
		free(messagesj);
		return(-1);
	}
	strcat(file_locat,tempstr);

	h_zdsj=fopen(file_locat,"a");

	if( h_zdsj == NULL )

	{

		ProcessError(LOG_ERROR,"PCS_Convert_File: cannot open ",file_locat);

		

		free(messagesj);

		return(-1);

	}

	fseek(h_zdsj,0,SEEK_END);

	fputs(messagesj,h_zdsj);

	

	

	free(messagesj);

	fclose(h_zdsj);

	UpdateJSRZ_cved(Match_key,sjbh);

	return(0);

}



int qdqbconv(int key,char ch[2])

{

	if(key<0)

	return(-1);

	if(key<10)

	{

		ch[0]=(char) (key+48);

		ch[1]='\0';

		return(0);

	}

	if(key>31)

	return(-1);

	ch[0]=(char)(key+55);

	ch[1]='\0';

}



int ConvertPDYSSJ(char *tempstring,char *messagesj,long int key,char *sjbh)

{

	int num_zjfs,round_count,i;

	char zfjbh[SHORT_LEN];

	char tempstr[MID_LEN];

	

/*	strcpy(messagesj,tempstring);*/

	EXEC SQL WHENEVER SQLERROR DO sqlerror();
	EXEC SQL SELECT count(*) INTO :round_count FROM t_jspdyssj 

		 WHERE jsxh=:key and sjbh=:sjbh; 

	EXEC SQL DECLARE cur_pdsj CURSOR FOR

		SELECT zjfs,zfjbh FROM t_jspdyssj WHERE jsxh=:key and sjbh=:sjbh;

	EXEC SQL OPEN cur_pdsj;

	messagesj[0]='\0';

	

	strcat(messagesj,tempstring);
	strcat(messagesj,"\n");
	for( i=0;i<round_count;i++ )

	{

		EXEC SQL FETCH cur_pdsj INTO :num_zjfs,:zfjbh;

		if( ERROR != 0 )
		{
			ERROR=0;
			ProcessError(LOG_ERROR,"PCS_CONVERT_FILE: error when get zjfs! ",END);
			EXEC SQL CLOSE cur_pdsj;
			return(-1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -