📄 dphssimc.pc
字号:
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_fieldchang出错");
return -1;
}
}
}
strcpy(lcsrowid,lccrowid);
strcpy(lcstype,lcctype);
for(k=0;k<6;k++)
{
lcchng0[k][0]=0;
lcnewg0[k][0]=0;
lcoldg0[k][0]=0;
}
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]);
} /*不同记录序号或者到最后一条记录处理结束*/
} /*for循环结束*/
return 0;
}
/*
* 函数说明:生成pdn_prod_prop信息
* 输入参数:
* 输出参数:
* 返 回 值:
*/
int intoPdn_prod_propProc()
{
EXEC SQL BEGIN DECLARE SECTION;
char lcnewg1[6][102] = {0};
char lcoldg1[6][102] = {0};
char lcfieldg1[6][20] = {0};
char lcchng1[6][40] = {0};
char lctypeg1[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_prod_prop",gitimes,gcdelflag,"0",gcsrv_code);
if (gcretval == -1)
{
strcat(gcretstr,"初始化pdn_prod_prop出错");
return -1;
}
if (gig1e == -1)
{
return 0;
}
for(k=0;k<6;k++)
{
lcfieldg1[k][0]=0;
lcchng1[k][0]=0;
lctypeg1[k][0]=0;
lcnewg1[k][0]=0;
lcoldg1[k][0]=0;
}
/*预先从dc_sysfields中取出字段和类型,保存在lcfieldg1和lctypeg1中*/
EXEC SQL SELECT field_code,field_type INTO :lcfieldg1,:lctypeg1 FROM dc_sysfields WHERE table_code = 'pdn_prod_prop' ORDER BY fld_id;
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"检索dc_sysfields出错");
return -1;
}
for(j=0;j<6;j++)
{
trim(lcfieldg1[j]);
trim(lctypeg1[j]);
}
ncpyRec(gig1s,5,lcstype,5);
trim(lcstype);
ncpyRec(gig1s,6,lcsrowid,5);
trim(lcsrowid);
for(j=gig1s;j<=gig1e;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 != gig1e))
{
ncpyRec(j,3,lcchng1[lisub],40);
trim(lcchng1[lisub]);
ncpyRec(j,7,lcnewg1[lisub],102);
trim(lcnewg1[lisub]);
ncpyRec(j,8,lcoldg1[lisub],102);
trim(lcoldg1[lisub]);
}
else /*不同记录序号或者到最后一条记录处理开始*/
{
if (j == gig1e)
{
ncpyRec(j,3,lcchng1[lisub],40);
trim(lcchng1[lisub]);
ncpyRec(j,7,lcnewg1[lisub],102);
trim(lcnewg1[lisub]);
ncpyRec(j,8,lcoldg1[lisub],102);
trim(lcoldg1[lisub]);
}
/*保存生产编号、生产类型到数组*/
strcpy(lcoldg1[0],gcproduce_id);
strcpy(lcnewg1[0],gcproduce_id);
strcpy(lcchng1[0],"生产编号");
strcpy(lcoldg1[1],"1");
strcpy(lcnewg1[1],"1");
strcpy(lcchng1[1],"生产类型");
/*拼装SQL语句开始*/
if (lcstype[0] == 'D') /*删除*/
{
strcpy(lcdelete,"DELETE FROM pdn_prod_prop");
}
else if (lcstype[0] == 'A') /*增加*/
{
strcpy(lcinsert,"INSERT INTO pdn_prod_prop(");
strcpy(lcvalues," VALUES(");
}
else if (lcstype[0] == 'M') /*修改*/
{
strcpy(lcupdate,"UPDATE pdn_prod_prop SET ");
}
for(i=0;i<6;i++)
{
/*拼装SQL语句处理*/
if (lcstype[0] == 'D')
{
}
else if (lcstype[0] == 'A')
{
if ((strcmp(lctypeg1[i],"date") != 0)&&(lcchng1[i][0] != 0))
{
strcat(lcinsert,lcfieldg1[i]);
strcat(lcinsert,",");
strcat(lcvalues,"'");
strcat(lcvalues,lcnewg1[i]);
strcat(lcvalues,"',");
}
else if ((strcmp(lctypeg1[i],"date") == 0)&&(lcchng1[i][0] != 0))
{
strcat(lcinsert,lcfieldg1[i]);
strcat(lcinsert,",");
strcat(lcvalues,"to_date('");
strcat(lcvalues,lcnewg1[i]);
strcat(lcvalues,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
else if (lcstype[0] == 'M')
{
if ((strcmp(lctypeg1[i],"date") != 0)&&(lcchng1[i][0] != 0))
{
strcat(lcupdate,lcfieldg1[i]);
strcat(lcupdate," = '");
strcat(lcupdate,lcnewg1[i]);
strcat(lcupdate,"',");
}
else if ((strcmp(lctypeg1[i],"date") == 0)&&(lcchng1[i][0] != 0))
{
strcat(lcupdate,lcfieldg1[i]);
strcat(lcupdate," = to_date('");
strcat(lcupdate,lcnewg1[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,lcoldg1[3]);
strcat(lcwhere,"' AND item_code = '");
strcat(lcwhere,lcoldg1[4]);
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,lcoldg1[3]);
strcat(lcwhere,"' AND item_code = '");
strcat(lcwhere,lcoldg1[4]);
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_prod_prop新记录出错");
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_prod_prop',:lcsrowid,:gcproduct_id,:lcstype);
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_chantype出错");
return -1;
}
for(k=0;k<6;k++)
{
if (lcchng1[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_prod_prop',:lcfieldg1[k],:lcchng1[k],:lcsrowid,:gcproduct_id,:lctypeg1[k],:lcnewg1[k],:lcoldg1[k],:gcsrv_code,:k);
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"插入pdn_fieldchang出错");
return -1;
}
}
}
strcpy(lcsrowid,lccrowid);
strcpy(lcstype,lcctype);
for(k=0;k<6;k++)
{
lcchng1[k][0]=0;
lcnewg1[k][0]=0;
lcoldg1[k][0]=0;
}
ncpyRec(j,3,lcchng1[lisub],40);
trim(lcchng1[lisub]);
ncpyRec(j,7,lcnewg1[lisub],102);
trim(lcnewg1[lisub]);
ncpyRec(j,8,lcoldg1[lisub],102);
trim(lcoldg1[lisub]);
} /*不同记录序号或者到最后一条记录处理结束*/
} /*for循环结束*/
return 0;
}
/*
* 函数说明:生成pdn_device信息
* 输入参数:
* 输出参数:
* 返 回 值:
*/
int intoPdn_deviceProc()
{
EXEC SQL BEGIN DECLARE SECTION;
char lcnewa5[8][60] = {0};
char lcolda5[8][60] = {0};
char lcfielda5[8][20] = {0};
char lcchna5[8][40] = {0};
char lctypea5[8][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_device",gitimes,gcdelflag,"0",gcsrv_code);
if (gcretval == -1)
{
strcat(gcretstr,"初始化pdn_device出错");
return -1;
}
if (gia5e == -1)
{
return 0;
}
for(k=0;k<8;k++)
{
lcfielda5[k][0]=0;
lcchna5[k][0]=0;
lctypea5[k][0]=0;
lcnewa5[k][0]=0;
lcolda5[k][0]=0;
}
/*预先从dc_sysfields中取出字段和类型,保存在lcfielda5和lctypea5中*/
EXEC SQL SELECT field_code,field_type INTO :lcfielda5,:lctypea5 FROM dc_sysfields WHERE table_code = 'pdn_device' ORDER BY fld_id;
if (sqlca.sqlcode < 0)
{
strcat(gcretstr,"检索dc_sysfields出错");
return -1;
}
for(j=0;j<8;j++)
{
trim(lcfielda5[j]);
trim(lctypea5[j]);
}
ncpyRec(gia5s,5,lcstype,5);
trim(lcstype);
ncpyRec(gia5s,6,lcsrowid,5);
trim(lcsrowid);
for(j=gia5s;j<=gia5e;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 != gia5e))
{
ncpyRec(j,3,lcchna5[lisub],40);
trim(lcchna5[lisub]);
ncpyRec(j,7,lcnewa5[lisub],60);
trim(lcnewa5[lisub]);
ncpyRec(j,8,lcolda5[lisub],60);
trim(lcolda5[lisub]);
#ifdef YYDEBUG
DebugLog("lisub=%d,field=%s",lisub,lcfielda5[lisub]);
DebugLog("lisub=%d,chn=%s",lisub,lcchna5[lisub]);
DebugLog("lisub=%d,data=%s",lisub,lctypea5[lisub]);
DebugLog("lisub=%d,new=%s",lisub,lcnewa5[lisub]);
DebugLog("lisub=%d,old=%s",lisub,lcolda5[lisub]);
#endif
}
else /*不同记录序号或者到最后一条记录处理开始*/
{
if (j == gia5e)
{
ncpyRec(j,3,lcchna5[lisub],40);
trim(lcchna5[lisub]);
ncpyRec(j,7,lcnewa5[lisub],60);
trim(lcnewa5[lisub]);
ncpyRec(j,8,lcolda5[lisub],60);
trim(lcolda5[lisub]);
}
/*保存生产编号、生产类型到数组*/
strcpy(lcolda5[0],gcproduce_id);
strcpy(lcnewa5[0],gcproduce_id);
strcpy(lcchna5[0],"生产编号");
strcpy(lcolda5[1],"1");
strcpy(lcnewa5[1],"1");
strcpy(lcchna5[1],"生产类型");
/*拼装SQL语句开始*/
if (lcstype[0] == 'D') /*删除*/
{
strcpy(lcdelete,"DELETE FROM pdn_device");
}
else if (lcstype[0] == 'A') /*增加*/
{
strcpy(lcinsert,"INSERT INTO pdn_device(");
strcpy(lcvalues," VALUES(");
}
else if (lcstype[0] == 'M') /*修改*/
{
strcpy(lcupdate,"UPDATE pdn_device SET ");
}
for(i=0;i<8;i++)
{
/*拼装SQL语句处理*/
if (lcstype[0] == 'D')
{
}
else if (lcstype[0] == 'A')
{
if ((strcmp(lctypea5[i],"date") != 0)&&(lcchna5[i][0] != 0))
{
strcat(lcinsert,lcfielda5[i]);
strcat(lcinsert,",");
strcat(lcvalues,"'");
strcat(lcvalues,lcnewa5[i]);
strcat(lcvalues,"',");
}
else if ((strcmp(lctypea5[i],"date") == 0)&&(lcchna5[i][0] != 0))
{
strcat(lcinsert,lcfielda5[i]);
strcat(lcinsert,",");
strcat(lcvalues,"to_date('");
strcat(lcvalues,lcnewa5[i]);
strcat(lcvalues,"','YYYY-MM-DD HH24:MI:SS'),");
}
}
else if (lcstype[0] == 'M')
{
if ((strcmp(lctypea5[i],"date") != 0)&&(lcchna5[i][0] != 0))
{
strcat(lcupdate,lcfielda5[i]);
strcat(lcupdate," = '");
strcat(lcupdate,lcnewa5[i]);
strcat(lcupdate,"',");
}
else if ((strcmp(lctypea5[i],"date") == 0)&&(lcchna5[i][0] != 0))
{
strcat(lcupdate,lcfielda5[i]);
strcat(lcupdate," = to_date('");
strcat(lcupdate,lcnewa5[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 device_code = '");
strcat(lcwhere,lcolda5[3]);
strcat(lcwhere,"' AND device_sour = '");
strcat(lcwhere,lcolda5[5]);
strcat(lcwhere,"' AND send_tache = '");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -