查未用的手編號表

来源:互联网 发布:采购一般用哪些软件 编辑:程序博客网 时间:2024/06/04 23:30
LPARA nTempConnect,nTempTableName,nTempTableName1,nTempWhere&&此句必須請不要刪除(<連接句柄>,<主表表名>,<返回的臨時表名>,<查詢的條件>)
IF SQLEXEC(nTempConnect,"SELECT zzordref ordref FROM "+nTempTableName+" where len(zzordref)>0 "+iif(empty(nTempWhere),""," and "+nTempWhere)+"  group by zzordref order by zzordref","aa")<=0
   RETU
ENDIF
*!* 數字開頭的﹕
crea cursor numtab(ordref c(20))
sele val(ordref) ordref from aa where ordref>"0" and ordref<"9" INTO CURSOR bb
sele bb
calculate max(ordref) to maxref
go 1
FOR I=11355 to maxref
    LOCATE FOR ordref=I
    IF !FOUND()
       sele numtab
       insert into numtab values (str(I))
    ENDIF
    sele bb
    go top
ENDFOR
*!* 字符開頭的﹕
dime cname(7)   
cname(1)="'RP'"
cname(2)="'SRP'"
cname(3)="'FP'"
cname(4)="'PH'"
cname(5)="'LF'"
cname(6)="'FRP'"
cname(7)="'CRP'"
dime minref(7)
minref(1)=1688
minref(2)=249
minref(3)=8043
minref(4)=103
minref(5)=261
minref(6)=154
minref(7)=2684
FOR K=1 TO 7
    sele nupart(ordref) ordref from aa where ordref like &cname(K)+'%' INTO CURSOR CC
    IF _TALLY>0
      sele cc 
      calculate max(ordref) to maxref
      go 1
      FOR J=minref(k) to maxref
          LOCATE FOR ordref=J
          IF !FOUND()
             sele numtab
             insert into numtab values (&cname(K)+alltrim(str(J)))
          ENDIF
          sele cc
          go top
      ENDFOR
   ENDIF
ENDF
sele alltrim(ordref) ordref from numtab INTO CURSOR (nTempTableName1) order by ordref
*********************************************************************
*  功    能: 得出一個字符串后面的數字                               *
*  用    法: NUPART(<數字>)                                         *
*  返 回 值: 字符串后面的數字                                       *      
*********************************************************************
FUNC NUPART
   LPARA AA
   LOCAL I,BB
   BB=0
   FOR I=1 TO LEN(AA)
       IF ISDI(SUBS(AA,I,1))
          BB=VAL(SUBSTR(AA,I))
          I=LEN(AA)+1
       ENDIF
   ENDFOR
   RETU BB
ENDFUNC
原创粉丝点击