📄 dphssimc.pc
字号:
}
for(j=0;j<PHONE_FIELD;j++)
{
trim(lcfielda1[j]);
trim(lctypea1[j]);
}
ncpyRec(gia1s,5,lcstype,5);
trim(lcstype);
ncpyRec(gia1s,6,lcsrowid,5);
trim(lcsrowid);
for(j=gia1s;j<=gia1e;j++)
{
ncpyRec(j,1,lcsub,3);
lisub=atoi(lcsub);
ncpyRec(j,5,lcctype,5);
trim(lcctype);
ncpyRec(j,6,lccrowid,5);
trim(lccrowid);
if ((strcmp(lcsrowid,lccrowid) == 0) && (j != gia1e))
{
ncpyRec(j,3,lcchna1[lisub],40);
trim(lcchna1[lisub]);
ncpyRec(j,7,lcnewa1[lisub],PHONE_LENGTH);
trim(lcnewa1[lisub]);
ncpyRec(j,8,lcolda1[lisub],PHONE_LENGTH);
trim(lcolda1[lisub]);
#ifdef YYDEBUG
DebugLog("lisub=%d,field=%s",lisub,lcfielda1[lisub]);
DebugLog("lisub=%d,chn=%s",lisub,lcchna1[lisub]);
DebugLog("lisub=%d,data=%s",lisub,lctypea1[lisub]);
DebugLog("lisub=%d,new=%s",lisub,lcnewa1[lisub]);
DebugLog("lisub=%d,old=%s",lisub,lcolda1[lisub]);
#endif
}
else /*不同记录序号或者到最后一条记录处理开始*/
{
if (j == gia1e)
{
ncpyRec(j,3,lcchna1[lisub],40);
trim(lcchna1[lisub]);
ncpyRec(j,7,lcnewa1[lisub],PHONE_LENGTH);
trim(lcnewa1[lisub]);
ncpyRec(j,8,lcolda1[lisub],PHONE_LENGTH);
trim(lcolda1[lisub]);
}
/*保存生产编号、生产类型到数组*/
strcpy(lcolda1[0],gcproduce_id);
strcpy(lcnewa1[0],gcproduce_id);
strcpy(lcchna1[0],"生产编号");
strcpy(lcolda1[1],"1");
strcpy(lcnewa1[1],"1");
strcpy(lcchna1[1],"生产类型");
/*判断是否需要生成电话编号*/
if ( (lcchna1[2][0] != 0) && (lcnewa1[2][0] == 0) && ((lcstype[0] == 'A')||(lcstype[0] == 'M')) )
{
sprintf(gcphone_id,"%d",GenPhoneidProc());
trim(gcphone_id);
if (strcmp(gcphone_id,"-1") == 0)
{
strcat(gcretstr,"生成电话编号出错");
return -1;
}
strcpy(lcnewa1[2],gcphone_id);
strcpy(lcchna1[2],"电话编号");
}
/*保存引示号*/
strcpy(gclead_no,lcnewa1[10]);
trim(gclead_no);
giswitch_id=atoi(lcnewa1[20]);
/*处理产品号码*/
if ((lcchna1[4][0] != 0) && (lcnewa1[4][0] == 0))
{
#ifdef YYDEBUG
DebugLog("gcprod_class=%s",gcprod_class);
DebugLog("gcprodexch_code=%s",gcprodexch_code);
DebugLog("giswitch_id=%d",giswitch_id);
DebugLog("gcprot_code=%s",gcprot_code);
#endif
EXEC SQL EXECUTE
BEGIN
P_Auto_Selenum(:gcprod_class,:gcprodexch_code,:giswitch_id,:gcprot_code,'',:gcoper_code,:gcproduct_no,:giprodno_grade,:gcretval,:gcretstr);
END;
END-EXEC;
if (gcretval < 0)
{
trim(gcretstr);
return -1;
}
trim(gcproduct_no);
strcpy(lcnewa1[4],gcproduct_no);
sprintf(lcnewa1[5],"%d",giprodno_grade);
strcpy(lcnewa1[6],"0");
trim(lcnewa1[4]);
trim(lcnewa1[5]);
trim(lcnewa1[6]);
}
/*拼装SQL语句开始*/
if (lcstype[0] == 'D') /*删除*/
{
strcpy(lcdelete,"DELETE FROM pdn_phone");
}
else if (lcstype[0] == 'A') /*增加*/
{
strcpy(lcinsert,"INSERT INTO pdn_phone(");
strcpy(lcvalues," VALUES(");
}
else if (lcstype[0] == 'M') /*修改*/
{
strcpy(lcupdate,"UPDATE pdn_phone SET ");
}
for(i=0;i<PHONE_FIELD;i++)
{
/*拼装SQL语句处理*/
if (lcstype[0] == 'D')
{
}
else if (lcstype[0] == 'A')
{
if ((strcmp(lctypea1[i],"date") != 0)&&(lcchna1[i][0] != 0))
{
strcat(lcinsert,lcfielda1[i]);
strcat(lcinsert,",");
strcat(lcvalues,"'");
strcat(lcvalues,lcnewa1[i]);
strcat(lcvalues,"',");
}
else if ((strcmp(lctypea1[i],"date") == 0)&&(lcchna1[i][0] != 0))
{
strcat(lcinsert,lcfielda1[i]);
strcat(lcinsert,",");
strcat(lcvalues,"to_date('");
strcat(lcvalues,lcnewa1[i]);
strcat(lcvalues,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
else if (lcstype[0] == 'M')
{
if ((strcmp(lctypea1[i],"date") != 0)&&(lcchna1[i][0] != 0))
{
strcat(lcupdate,lcfielda1[i]);
strcat(lcupdate," = '");
strcat(lcupdate,lcnewa1[i]);
strcat(lcupdate,"',");
}
else if ((strcmp(lctypea1[i],"date") == 0)&&(lcchna1[i][0] != 0))
{
strcat(lcupdate,lcfielda1[i]);
strcat(lcupdate," = to_date('");
strcat(lcupdate,lcnewa1[i]);
strcat(lcupdate,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
} /*fielchang的for循环结束*/
if (lcstype[0] == 'D')
{
strcpy(lcwhere," WHERE produce_id = '");
strcat(lcwhere,gcproduce_id);
strcat(lcwhere,"' AND produce_type = 1");
strcat(lcwhere," AND phone_id = '");
strcat(lcwhere,lcolda1[2]);
strcat(lcwhere,"'");
strcat(lcdelete,lcwhere);
strcpy(lcsql,lcdelete);
}
else if (lcstype[0] == 'A')
{
lcinsert[strlen(lcinsert) - 1] = 0;
strcat(lcinsert,")");
lcvalues[strlen(lcvalues) - 1] = 0;
strcat(lcvalues,")");
strcat(lcinsert,lcvalues);
strcpy(lcsql,lcinsert);
}
else if (lcstype[0] == 'M')
{
strcpy(lcwhere," WHERE produce_id = '");
strcat(lcwhere,gcproduce_id);
strcat(lcwhere,"' AND produce_type = 1");
strcat(lcwhere," AND phone_id = '");
strcat(lcwhere,lcolda1[2]);
strcat(lcwhere,"'");
lcupdate[strlen(lcupdate) - 1] = 0;
strcat(lcupdate,lcwhere);
strcpy(lcsql,lcupdate);
}
/*拼装SQL语句结束*/
EXEC SQL EXECUTE IMMEDIATE :lcsql;
if (sqlca.sqlcode < 0)
{
#ifdef YYDEBUG
DebugLog("lcsql=%s",lcsql);
#endif
strcat(gcretstr,"修改pdn_phone新记录出错");
return -1;
}
/*生成记录变动表*/
EXEC SQL INSERT INTO pdn_chantype(produce_id,produce_no,table_name,record_id,product_id,record_type)
VALUES(:gcproduce_id,:gcproduce_no,'pdn_phone',:lcsrowid,:gcproduct_id,:lcstype);
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_chantype出错");
return -1;
}
for(k=0;k<PHONE_FIELD;k++)
{
if (lcchna1[k][0] != 0)
{
EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
VALUES(:gcproduce_id,:gcproduce_no,'pdn_phone',:lcfielda1[k],:lcchna1[k],:lcsrowid,:gcproduct_id,:lctypea1[k],:lcnewa1[k],:lcolda1[k],:gcsrv_code,:k);
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_fieldchang出错");
return -1;
}
}
}
strcpy(lcsrowid,lccrowid);
strcpy(lcstype,lcctype);
for(k=0;k<PHONE_FIELD;k++)
{
lcchna1[k][0]=0;
lcnewa1[k][0]=0;
lcolda1[k][0]=0;
}
ncpyRec(j,3,lcchna1[lisub],40);
trim(lcchna1[lisub]);
ncpyRec(j,7,lcnewa1[lisub],PHONE_LENGTH);
trim(lcnewa1[lisub]);
ncpyRec(j,8,lcolda1[lisub],PHONE_LENGTH);
trim(lcolda1[lisub]);
} /*不同记录序号或者到最后一条记录处理结束*/
} /*for循环结束*/
return 0;
}
/*
* 函数说明:生成pdn_incr_prod信息
* 输入参数:
* 输出参数:
* 返 回 值:
*/
int intoPdn_incr_prodProc()
{
EXEC SQL BEGIN DECLARE SECTION;
char lcnewg0[6][12] = {0};
char lcoldg0[6][12] = {0};
char lcfieldg0[6][20] = {0};
char lcchng0[6][40] = {0};
char lctypeg0[6][10] = {0};
char lcinsert[2000] = {0};
char lcvalues[2000] = {0};
char lcupdate[2000] = {0};
char lcwhere[2000] = {0};
char lcdelete[2000] = {0};
char lcsql[2000] = {0};
char lcsrowid[5] = {0};
char lccrowid[5] = {0};
char lcstype[5] = {0};
char lcctype[5] = {0};
char lcsub[3] = {0};
int lisub=0;
int j=0;
int k=0;
int lirows=0;
EXEC SQL END DECLARE SECTION;
gcretval = DinitpdnProc(gcproduct_id,gcproduce_id,gcproduce_no,"pdn_incr_prod",gitimes,gcdelflag,"0",gcsrv_code);
if (gcretval == -1)
{
strcat(gcretstr,"初始化pdn_incr_prod出错");
return -1;
}
if (gig0e == -1)
{
return 0;
}
for(k=0;k<6;k++)
{
lcfieldg0[k][0]=0;
lcchng0[k][0]=0;
lctypeg0[k][0]=0;
lcnewg0[k][0]=0;
lcoldg0[k][0]=0;
}
/*预先从dc_sysfields中取出字段和类型,保存在lcfieldg0和lctypeg0中*/
EXEC SQL SELECT field_code,field_type INTO :lcfieldg0,:lctypeg0 FROM dc_sysfields WHERE table_code = 'pdn_incr_prod' ORDER BY fld_id;
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"检索dc_sysfields出错");
return -1;
}
for(j=0;j<6;j++)
{
trim(lcfieldg0[j]);
trim(lctypeg0[j]);
}
ncpyRec(gig0s,5,lcstype,5);
trim(lcstype);
ncpyRec(gig0s,6,lcsrowid,5);
trim(lcsrowid);
for(j=gig0s;j<=gig0e;j++)
{
ncpyRec(j,1,lcsub,3);
lisub=atoi(lcsub);
ncpyRec(j,5,lcctype,5);
trim(lcctype);
ncpyRec(j,6,lccrowid,5);
trim(lccrowid);
if ((strcmp(lcsrowid,lccrowid) == 0) && (j != gig0e))
{
ncpyRec(j,3,lcchng0[lisub],40);
trim(lcchng0[lisub]);
ncpyRec(j,7,lcnewg0[lisub],12);
trim(lcnewg0[lisub]);
ncpyRec(j,8,lcoldg0[lisub],12);
trim(lcoldg0[lisub]);
}
else /*不同记录序号或者到最后一条记录处理开始*/
{
if (j == gig0e)
{
ncpyRec(j,3,lcchng0[lisub],40);
trim(lcchng0[lisub]);
ncpyRec(j,7,lcnewg0[lisub],12);
trim(lcnewg0[lisub]);
ncpyRec(j,8,lcoldg0[lisub],12);
trim(lcoldg0[lisub]);
}
/*保存生产编号、生产类型到数组*/
strcpy(lcoldg0[0],gcproduce_id);
strcpy(lcnewg0[0],gcproduce_id);
strcpy(lcchng0[0],"生产编号");
strcpy(lcoldg0[1],"1");
strcpy(lcnewg0[1],"1");
strcpy(lcchng0[1],"生产类型");
/*拼装SQL语句开始*/
if (lcstype[0] == 'D') /*删除*/
{
strcpy(lcdelete,"DELETE FROM pdn_incr_prod");
}
else if (lcstype[0] == 'A') /*增加*/
{
strcpy(lcinsert,"INSERT INTO pdn_incr_prod(");
strcpy(lcvalues," VALUES(");
}
else if (lcstype[0] == 'M') /*修改*/
{
strcpy(lcupdate,"UPDATE pdn_incr_prod SET ");
}
for(i=0;i<6;i++)
{
/*拼装SQL语句处理*/
if (lcstype[0] == 'D')
{
}
else if (lcstype[0] == 'A')
{
if ((strcmp(lctypeg0[i],"date") != 0)&&(lcchng0[i][0] != 0))
{
strcat(lcinsert,lcfieldg0[i]);
strcat(lcinsert,",");
strcat(lcvalues,"'");
strcat(lcvalues,lcnewg0[i]);
strcat(lcvalues,"',");
}
else if ((strcmp(lctypeg0[i],"date") == 0)&&(lcchng0[i][0] != 0))
{
strcat(lcinsert,lcfieldg0[i]);
strcat(lcinsert,",");
strcat(lcvalues,"to_date('");
strcat(lcvalues,lcnewg0[i]);
strcat(lcvalues,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
else if (lcstype[0] == 'M')
{
if ((strcmp(lctypeg0[i],"date") != 0)&&(lcchng0[i][0] != 0))
{
strcat(lcupdate,lcfieldg0[i]);
strcat(lcupdate," = '");
strcat(lcupdate,lcnewg0[i]);
strcat(lcupdate,"',");
}
else if ((strcmp(lctypeg0[i],"date") == 0)&&(lcchng0[i][0] != 0))
{
strcat(lcupdate,lcfieldg0[i]);
strcat(lcupdate," = to_date('");
strcat(lcupdate,lcnewg0[i]);
strcat(lcupdate,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
} /*fielchang的for循环结束*/
if (lcstype[0] == 'D')
{
strcpy(lcwhere," WHERE produce_id = '");
strcat(lcwhere,gcproduce_id);
strcat(lcwhere,"' AND produce_type = 1");
strcat(lcwhere," AND prod_class = '");
strcat(lcwhere,lcoldg0[3]);
strcat(lcwhere,"'");
strcat(lcdelete,lcwhere);
strcpy(lcsql,lcdelete);
}
else if (lcstype[0] == 'A')
{
lcinsert[strlen(lcinsert) - 1] = 0;
strcat(lcinsert,")");
lcvalues[strlen(lcvalues) - 1] = 0;
strcat(lcvalues,")");
strcat(lcinsert,lcvalues);
strcpy(lcsql,lcinsert);
}
else if (lcstype[0] == 'M')
{
strcpy(lcwhere," WHERE produce_id = '");
strcat(lcwhere,gcproduce_id);
strcat(lcwhere,"' AND produce_type = 1");
strcat(lcwhere," AND prod_class = '");
strcat(lcwhere,lcoldg0[3]);
strcat(lcwhere,"'");
lcupdate[strlen(lcupdate) - 1] = 0;
strcat(lcupdate,lcwhere);
strcpy(lcsql,lcupdate);
}
/*拼装SQL语句结束*/
EXEC SQL EXECUTE IMMEDIATE :lcsql;
if (sqlca.sqlcode < 0)
{
#ifdef YYDEBUG
DebugLog("lcsql=%s",lcsql);
#endif
strcat(gcretstr,"修改pdn_incr_prod新记录出错");
return -1;
}
/*生成记录变动表*/
EXEC SQL INSERT INTO pdn_chantype(produce_id,produce_no,table_name,record_id,product_id,record_type)
VALUES(:gcproduce_id,:gcproduce_no,'pdn_incr_prod',:lcsrowid,:gcproduct_id,:lcstype);
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_chantype出错");
return -1;
}
for(k=0;k<6;k++)
{
if (lcchng0[k][0] != 0)
{
EXEC SQL INSERT INTO pdn_fieldchang(produce_id,produce_no,table_name,field_name,field_memo,record_id,product_id,field_type,new_value,old_value,srv_code,fld_id)
VALUES(:gcproduce_id,:gcproduce_no,'pdn_incr_prod',:lcfieldg0[k],:lcchng0[k],:lcsrowid,:gcproduct_id,:lctypeg0[k],:lcnewg0[k],:lcoldg0[k],:gcsrv_code,:k);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -