with Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select b.item_code, b.spec, b.thick, b.width, b.weight, .cif_pric ');
SQL.Add(' , b.cuff_sect, a.change_rate, b.duty_mony from ptet004 a, ptet005 b ');
SQL.Add(' where a.invo_date between :from_date and :to_date ');
SQL.Add(' and a.invo_no = b.invo_no ');
sql.add(' order by 1,2,3,4 ');
Parambyname('from_date').Asdate := g_from;
Parambyname('to_date').Asdate := g_to;
Open;
ProgressBar1.Max := Recordcount;
First;
while not eof do
begin
m_amount := 0.00;
Query3.Close;
Query3.ParamByName('gubn').Asstring := '1';
Query3.ParamByName('fin_yymm').Asstring := MaskEdit1.Text;
Query3.ParamByName('fin_gubn').Asstring := '11';
Query3.ParamByName('fin_kind').Asstring := fieldbyname('item_code').Asstring;
Query3.ParamByName('spec').Asstring := fieldbyname('spec').Asstring;
Query3.ParamByName('thick').Asfloat := fieldbyname('thick').Asfloat;
Query3.ParamByName('width').Asfloat := fieldbyname('width').Asfloat;
Query3.Open;
if Query3.RecordCount <> 1 then
begin
Query3.Append;
Query3gubn.Value := '1';
Query3fin_yymm.Value := MaskEdit1.Text;
Query3fin_gubn.Value := '11';
Query3fin_kind.Value := fieldbyname('item_code').Asstring;
Query3spec.Value := fieldbyname('spec').Asstring;
Query3thick.Value := fieldbyname('thick').Asfloat;
Query3width.Value := fieldbyname('width').Asfloat;
Query3weight.Value := fieldbyname('weight').Asinteger;
if fieldbyname('cuff_sect').Asstring = 'D' then
begin
Query3amount.Value := strtofloat(formatfloat('########0.00',
(fieldbyname('cif_pric').Asfloat
* fieldbyname('change_rate').Asfloat))); Query3amount.Value := Query3amount.Value + fieldbyname('duty_mony').Asfloat;
end
else
Query3amount.Value := fieldbyname('cif_pric').Asfloat + fieldbyname('duty_mony').Asfloat; Query3price.Value := strtofloat(formatfloat('#####0.00',(Query3amount.Value
/ Query3weight.Value)));
Query3in_date.Value := date;
Query3in_user.Value := ParamStr(1);
Query3.Post;
end
else
begin
Query3.Edit;
Query3weight.Value := Query3weight.Value + fieldbyname('weight').Asinteger;
if fieldbyname('cuff_sect').Asstring = 'D' then
begin
Query3amount.Value := Query3amount.Value +
strtofloat(formatfloat('########0.00',
(fieldbyname('cif_pric').Asfloat
* fieldbyname('change_rate').Asfloat)+
fieldbyname('duty_mony').Asfloat));
end
else
Query3amount.Value := Query3amount.Value +
fieldbyname('cif_pric').Asfloat + fieldbyname('duty_mony').Asfloat;
Query3price.Value := strtofloat(formatfloat('#####0.00',(Query3amount.Value
/ Query3weight.Value)));
Query3.Post;
end;
ProgressBar1.StepBy(1);
Next;
end;
end;
这段程序向query3中插入纪录时总出现唯一索引重复插不进去,可是通过检查query1中的纪录没有数据问题(用pb和sql测试) ,作为条件在query3中检索的条件列为query3的唯一索引。
实际情况应为query1中的第五行在插入到query3时应该检索到一条唯一索引相同的纪录,应该recordcount = 1 的情况(else),将相关数值累加更新query3中现有纪录,可是现在检索不到query3中的这条纪录,执行了 recordcount <> 1 的情况,这时就发生了唯一索引重复的错误。不知小妹说清楚了没有,情况紧急还请大侠们帮忙!!!
begin
Close;
SQL.Clear;
SQL.Add('select b.item_code, b.spec, b.thick, b.width, b.weight, .cif_pric ');
SQL.Add(' , b.cuff_sect, a.change_rate, b.duty_mony from ptet004 a, ptet005 b ');
SQL.Add(' where a.invo_date between :from_date and :to_date ');
SQL.Add(' and a.invo_no = b.invo_no ');
sql.add(' order by 1,2,3,4 ');
Parambyname('from_date').Asdate := g_from;
Parambyname('to_date').Asdate := g_to;
Open;
ProgressBar1.Max := Recordcount;
First;
while not eof do
begin
m_amount := 0.00;
Query3.Close;
Query3.ParamByName('gubn').Asstring := '1';
Query3.ParamByName('fin_yymm').Asstring := MaskEdit1.Text;
Query3.ParamByName('fin_gubn').Asstring := '11';
Query3.ParamByName('fin_kind').Asstring := fieldbyname('item_code').Asstring;
Query3.ParamByName('spec').Asstring := fieldbyname('spec').Asstring;
Query3.ParamByName('thick').Asfloat := fieldbyname('thick').Asfloat;
Query3.ParamByName('width').Asfloat := fieldbyname('width').Asfloat;
Query3.Open;
if Query3.RecordCount <> 1 then
begin
Query3.Append;
Query3gubn.Value := '1';
Query3fin_yymm.Value := MaskEdit1.Text;
Query3fin_gubn.Value := '11';
Query3fin_kind.Value := fieldbyname('item_code').Asstring;
Query3spec.Value := fieldbyname('spec').Asstring;
Query3thick.Value := fieldbyname('thick').Asfloat;
Query3width.Value := fieldbyname('width').Asfloat;
Query3weight.Value := fieldbyname('weight').Asinteger;
if fieldbyname('cuff_sect').Asstring = 'D' then
begin
Query3amount.Value := strtofloat(formatfloat('########0.00',
(fieldbyname('cif_pric').Asfloat
* fieldbyname('change_rate').Asfloat))); Query3amount.Value := Query3amount.Value + fieldbyname('duty_mony').Asfloat;
end
else
Query3amount.Value := fieldbyname('cif_pric').Asfloat + fieldbyname('duty_mony').Asfloat; Query3price.Value := strtofloat(formatfloat('#####0.00',(Query3amount.Value
/ Query3weight.Value)));
Query3in_date.Value := date;
Query3in_user.Value := ParamStr(1);
Query3.Post;
end
else
begin
Query3.Edit;
Query3weight.Value := Query3weight.Value + fieldbyname('weight').Asinteger;
if fieldbyname('cuff_sect').Asstring = 'D' then
begin
Query3amount.Value := Query3amount.Value +
strtofloat(formatfloat('########0.00',
(fieldbyname('cif_pric').Asfloat
* fieldbyname('change_rate').Asfloat)+
fieldbyname('duty_mony').Asfloat));
end
else
Query3amount.Value := Query3amount.Value +
fieldbyname('cif_pric').Asfloat + fieldbyname('duty_mony').Asfloat;
Query3price.Value := strtofloat(formatfloat('#####0.00',(Query3amount.Value
/ Query3weight.Value)));
Query3.Post;
end;
ProgressBar1.StepBy(1);
Next;
end;
end;
这段程序向query3中插入纪录时总出现唯一索引重复插不进去,可是通过检查query1中的纪录没有数据问题(用pb和sql测试) ,作为条件在query3中检索的条件列为query3的唯一索引。
实际情况应为query1中的第五行在插入到query3时应该检索到一条唯一索引相同的纪录,应该recordcount = 1 的情况(else),将相关数值累加更新query3中现有纪录,可是现在检索不到query3中的这条纪录,执行了 recordcount <> 1 的情况,这时就发生了唯一索引重复的错误。不知小妹说清楚了没有,情况紧急还请大侠们帮忙!!!
解决方案 »
- 年底了有找delphi工作的吗?
- 线程的定时
- 如果用delphi该怎么写
- Delphi中有没有现成的message queue啊
- 如何使show出的form先是在最前
- ********难道没有人能解决我的DBGrid简单问题吗,88分,新年给个吉利分********
- a:=AnsiResemblesText(self.Edit1.Text,self.Edit2.Text);//提示错误:Error] Unit1.pas(32): Undeclared identifier: 'AnsiResemblesText
- delphi中用sendmessage发布消息(在线等待,一定给分)
- 来一起研究和学习delphi6--(不是关于delphi6的功能介绍、特性、技巧请不要贴)
- DELPHI与COM!!!
- MDI主窗体de问题
- 用Delphi7 的dbExpress連接sql server 时,sqldataset的commandtext是找不到表
Query3.ParamByName('fin_yymm').Asstring := MaskEdit1.Text;
Query3.ParamByName('fin_gubn').Asstring := '11';
Query3.ParamByName('fin_kind').Asstring := fieldbyname'item_code').Asstring;
Query3.ParamByName('spec').Asstring := fieldbyname('spec').Asstring;
Query3.ParamByName('thick').Asfloat := fieldbyname('thick').Asfloat;
Query3.ParamByName('width').Asfloat := fieldbyname('width').Asfloat;是这些字段,是informix数据库
有的话把跟踪到的Sql语句查询一下,看看有什么问题?
and fin_yymm = :fin_yymm and fin_gubn = :fin_gubn
and fin_kind = :fin_kind and spec = :spec
and thick = :thick and width = :width
还是把Query3的Sql语句帖出来看看吧。这东西难说清楚,要是在场的话就很容易搞定了。
什么破老板嘛,炒了呀的。
检索不出?!这不可能吧?这应该与“delphi环境的问题”无关!!!总之,研究!!!!!!