用了post,提示“monthpaytable:dataset not in edit or insert mode"
to zjting: 我用的是oracle数据库,我不知道怎么把表拿出来给你
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 ...
好象是这样: 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;
monthpaytable.appendrecord试试。
或设个断点,按F7单步执行,看看指针是否下移.
begin
monthpaytable.insertrecord
monthpaytable.post
end
若再不行,把这两个库发给我,我给你试试
[email protected]
我用的是oracle数据库,我不知道怎么把表拿出来给你
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 ...
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;
我有个问题,看**包围的三个字段,是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) ';