程序执行以下代码
qyhbpgb.Close;
qyhbpgb.SQL.Clear;
qyhbpgb.SQL.Add('select f.ddh as forder,f.pz as type2,f.gg as type3,m.type4 as type4,f.xs as xs,f.xjs as perpkg,f.rkxs as fyhqty,m.desccode from cpjcb f '+
'join invitem m on f.pz=m.type2 and f.gg=m.type3 and charindex(f.xs,m.bhxs)>0 where f.ddh='+''''+qysoctrl.fieldbyname('hisno').AsString+''' and isnull(f.rkxs,0)<>0');
qyhbpgb.open;
//从成品结存表中以出此订单中入库箱数>0的记录,且重新带新的工艺路线,以此为循环.
qyhbpgb.First;
while not qyhbpgb.Eof do
//1.6.B
begin
c:=trim(qyhbpgb.FieldByName('type2').Asstring)+' '+trim(qyhbpgb.FieldByName('type3').Asstring)+' '+trim(qyhbpgb.FieldByName('type4').Asstring);
qy3.Close;
qy3.SQL.Clear;
qy3.SQL.Add('select f.type2,f.type3,f.type4,f.upqt,m.desccode as gylx from itemdtl f join invitem m on f.type2=m.type2 and f.type3=m.type3 and f.type4=m.type4 where f.itemno='+''''+c+'''');
qy3.open;
qycpjcb.Close;
qycpjcb.SQL.Clear;
qycpjcb.SQL.Add('select * from cpjcb where ddh='+''''+qyhbpgb.fieldbyname('forder').AsString+''' and pz='+''''+qyhbpgb.fieldbyname('type2').AsString+''' and '+
'gg='+''''+qyhbpgb.fieldbyname('type3').AsString+''' and xs=substring('+''''+qyhbpgb.fieldbyname('forder').AsString+''',1,3) and xjs='+''''+qyhbpgb.fieldbyname('perpkg').AsString+'''');
qycpjcb.Open;
qycpjcb.Edit;
//成品结存表入库箱数-已入库,实际结存箱-已入库,实际结存箱,帐面结存箱
qycpjcb.FieldByName('rkxs').Value:=qycpjcb.fieldbyname('rkxs').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('sjjcx').Value:=qycpjcb.fieldbyname('sjjcx').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('zmjcx').Value:=qycpjcb.fieldbyname('zmjcx').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('gxsj').Value:=now;
qycpjcb.Post;(出现错误)
......
qyhbpgb.netx;
end;
单步执行在到qycpjcb.post;(出现错误)的时候提示‘无法在cpjcb中插入重复键’,cpjcb表的主键是ddh,pz,gg,xs,xjs,px奇怪的是adoquery在执行edit,post的时候会出现这个错误,有人知道吗?
qyhbpgb.Close;
qyhbpgb.SQL.Clear;
qyhbpgb.SQL.Add('select f.ddh as forder,f.pz as type2,f.gg as type3,m.type4 as type4,f.xs as xs,f.xjs as perpkg,f.rkxs as fyhqty,m.desccode from cpjcb f '+
'join invitem m on f.pz=m.type2 and f.gg=m.type3 and charindex(f.xs,m.bhxs)>0 where f.ddh='+''''+qysoctrl.fieldbyname('hisno').AsString+''' and isnull(f.rkxs,0)<>0');
qyhbpgb.open;
//从成品结存表中以出此订单中入库箱数>0的记录,且重新带新的工艺路线,以此为循环.
qyhbpgb.First;
while not qyhbpgb.Eof do
//1.6.B
begin
c:=trim(qyhbpgb.FieldByName('type2').Asstring)+' '+trim(qyhbpgb.FieldByName('type3').Asstring)+' '+trim(qyhbpgb.FieldByName('type4').Asstring);
qy3.Close;
qy3.SQL.Clear;
qy3.SQL.Add('select f.type2,f.type3,f.type4,f.upqt,m.desccode as gylx from itemdtl f join invitem m on f.type2=m.type2 and f.type3=m.type3 and f.type4=m.type4 where f.itemno='+''''+c+'''');
qy3.open;
qycpjcb.Close;
qycpjcb.SQL.Clear;
qycpjcb.SQL.Add('select * from cpjcb where ddh='+''''+qyhbpgb.fieldbyname('forder').AsString+''' and pz='+''''+qyhbpgb.fieldbyname('type2').AsString+''' and '+
'gg='+''''+qyhbpgb.fieldbyname('type3').AsString+''' and xs=substring('+''''+qyhbpgb.fieldbyname('forder').AsString+''',1,3) and xjs='+''''+qyhbpgb.fieldbyname('perpkg').AsString+'''');
qycpjcb.Open;
qycpjcb.Edit;
//成品结存表入库箱数-已入库,实际结存箱-已入库,实际结存箱,帐面结存箱
qycpjcb.FieldByName('rkxs').Value:=qycpjcb.fieldbyname('rkxs').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('sjjcx').Value:=qycpjcb.fieldbyname('sjjcx').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('zmjcx').Value:=qycpjcb.fieldbyname('zmjcx').AsInteger-qyhbpgb.fieldbyname('fyhqty').AsInteger;
qycpjcb.FieldByName('gxsj').Value:=now;
qycpjcb.Post;(出现错误)
......
qyhbpgb.netx;
end;
单步执行在到qycpjcb.post;(出现错误)的时候提示‘无法在cpjcb中插入重复键’,cpjcb表的主键是ddh,pz,gg,xs,xjs,px奇怪的是adoquery在执行edit,post的时候会出现这个错误,有人知道吗?
qy1.edit;
qy1.fieldbyname('a').value:='b';
qy1.post;
执行post的是否提示‘不允许插入重复键’;这是怎么回事?