CREATE CURSOR test (lbdm c(10), xh c(9)) INSERT INTO test (lbdm) VALUES ("01") INSERT INTO test (lbdm) VALUES ("01") INSERT INTO test (lbdm) VALUES ("01") INSERT INTO test (lbdm) VALUES ("02") INSERT INTO test (lbdm) VALUES ("02") INSERT INTO test (lbdm) VALUES ("02") INSERT INTO test (lbdm) VALUES ("02") INSERT INTO test (lbdm) VALUES ("03") INSERT INTO test (lbdm) VALUES ("03") lcdm = SPACE(0) lcxh = "071201" SCAN IF lbdm == lcdm lnxh = lnxh + 1 ELSE lcdm = lbdm lnxh = 1 ENDIF REPLACE xh WITH lcxh + PADL(lnxh,3,"0") ENDSCAN BROWSE
Select lbdm,Count(*) rs From ceshi Group By 1 Into Array alcxh&&&ceshi为原表名 Select ceshi Blank Fields xh All&&&增加测试用 Go Top For i=1 To Alen(alcxh,1) For j=1 To alcxh[i,2] Replace xh With "0712"+Alltrim(lbdm)+Padl(j,3,"0") If Not Eof() Skip 1 Else Exit Endif Endfor Endfor Browse
[此贴子已经被作者于2024-6-9 05:48编辑过]