数据库中每口井有一个字段名成是深度,为了画图需要,深度之间的间隔若是超过0.3就要在上一个深度值下面插入一新列,其中深度=上一口井的深度+0.3 例如上一个深度值为  1005.6 下一个深度值为1006.9  那么在两个记录之间要插入1005.9,这个值的纪录  除了深度值与上一个记录不同之外其余全为上一条记录  access数据库  请问程序如何实现

解决方案 »

  1.   

    电视剧场刚卖广告,随手写一个,不知是否行,楼主你自已调试一下.
    前题:
    1.用两个ADOQUERY控件,SQL语句相同,如有排序,排序也必须相同.procedure TForm1.Button1Click(Sender: TObject);
    var
    sflat:Double;
    begin
     sflat:=0;
     with adoquery1 do begin
       if not Active then open;
       if not adoquery2.Active then adoquery2.Open;
       while not eof do begin
        if sflat<>0 then begin
          if FieldValues['深度']-sflat>0.3 then begin
           adoquery2.Prior;
           adoquery2.Insert;
           adoquery2.FieldValues['深度']:=sflat+0.3;
           adoquery2.Post;
           adoquery2.MoveBy(2);
          end else
           adoquery2.Next;
        end else begin
         sflat:=FieldValues['深度'];
         adoquery2.Next;
        end;
       next;
       end;
     end;
    end;
      

  2.   

    前题: 
    1.用两个ADOQUERY控件,SQL语句相同,如有排序,排序也必须相同. 
    procedure TForm1.Button1Click(Sender: TObject);
    var
    sflat:Double;
    begin
     with adoquery1 do begin
       if not Active then open;
       if not adoquery2.Active then adoquery2.Open;
       First;
       adoquery2.First;
       sflat:=FieldValues['深度'];
       next;
       adoquery2.Next;
       while not eof do begin
          if FieldValues['深度']-sflat>0.3 then begin
           adoquery2.Prior;
           adoquery2.Insert;
           adoquery2.FieldValues['深度']:=sflat+0.3;
           adoquery2.Post;
           adoquery2.MoveBy(2);
          end else
          adoquery2.Next;
       sflat:=FieldValues['深度'];
       next;
       end;
     end;
    end;