是不是这样写法导致指针一直指向welfare表中第一个记录呀,那怎么修改呢?

解决方案 »

  1.   

    这样做肯定指针只是指向welfare表的第一个记录.也是新手.咱们切磋一下.
      

  2.   

    把monthpaytable.insertrecord语句改为
    monthpaytable.appendrecord试试。
    或设个断点,按F7单步执行,看看指针是否下移.
      

  3.   

    哦,查过了,是不下移得,我换了appendrecord也是不下移得,为什么呢?
      

  4.   

    while
    begin
    monthpaytable.insertrecord
          
    monthpaytable.post
    end
      

  5.   

    把welfaretable库pack一下试试,
    若再不行,把这两个库发给我,我给你试试
    [email protected]
      

  6.   

    用了post,提示“monthpaytable:dataset not in edit or insert mode"
      

  7.   

    to zjting:
    我用的是oracle数据库,我不知道怎么把表拿出来给你
      

  8.   

    with welfaretable do
        begin
        open;
        first;
        while not eof do
        begin
          monthpaytable.insertrecord
          ([formatdatetime('yyyy-mm-dd',now),
          fieldbyname('ecode').asstring,
          .........
          fieldbyname('factpay').ascurrency]);
          monthpaytable.post;
          next;
        end;
        database1.ApplyUpdates([monthpaytable]);
        monthpaytable.commitupdates;
      end;
    不过你这种方法也太没有效率了,其实只用一个SQL语句就可以完成以上的功能
    insert into monthpaytable(...)
    select convert(Char[10],GetDate(),120),...
    from welfaretable 
    where ...
      

  9.   

    好象是这样:
    with welfaretable do
        begin
        open;
        first;
    ////////////////
        while not eof do
        begin
          monthpaytable.insertrecord
          ([formatdatetime('yyyy-mm-dd',now),
          fieldbyname('ecode').asstring,
          .........
          fieldbyname('factpay').ascurrency]);
          next;
          monthpaytable.next;//注意这里!     end;
    ////////////////
        database1.ApplyUpdates([monthpaytable]);
        monthpaytable.commitupdates;
      end; 
     
      

  10.   

    是Oracle数据库就更不应该使这么没效率的方法,发送SQL吧,查查Oracle的类型转化函数就行了,我写的是SQL Server的写法
      

  11.   

    to wangxd1976(西门吹雪):
    我有个问题,看**包围的三个字段,是e_welfare里本身没有的,但是我通过一个table控件(talbe1)建立了那三个新字段,并已经在oncalcfield里写入程序,那我在mysql里应该怎样调用呢?
    mysql:='insert into e_month_pay(paydate,ecode,housingp,agedp,umemployp,'
            +'medicalp,normalpay,titlea,booka,housinga,traffica,fooda,singlea,'
            +'daycheckplus,daycheckminu,rewardplus,punishminu,shouldpay,'
            +'deducepay,factpay) (select sysdate,ecode,housingp,agedp,umemployp,'
            +'medicalp,normalpay,titlea,booka,housinga,traffica,fooda,singlea,'
            +'daycheckplus,daycheckminu,rewardplus,punishminu,**shouldpay,'
            +'deducepay,factpay** from e_welfare) ';
      

  12.   

    还有convert是必须写的吗?有什么用呀?
      

  13.   

    convert是SQL SERVER 里的语法啦!转换用!