关于删除字段的问题,在线等待,高手请进,急啊!!

时间:2022-09-18 18:40:41
各位大侠,帮帮忙谢谢
用vf如何实现
一个表中有m个字段,比如x1,x2,x3……xm 其中m可能是3,也可能是5 
删除(m个字段同时为0)的记录

9 个解决方案

#1


Didn't remember exactly VFP syntax, 


select tableName

scan
  bDelete = .T.
  for iField to m 
     sField = "X" + str(i)
     if (&sField != 0)
         bDelete = .F.
         exit
     endif
  next
  if (bDelete)
     Delete Recno()
  endif
endscan

#2


lnNum=3
lcFilter="Where 0"
For lnI=1 To lnNum
lcFilter=lcFilter+"+x"+Transform(lnI)
Endfor
lcFilter=lcFilter+"=0"
Delete From 表名 &lcFilter.

#3


你说的不是很清楚,也没有举例,所以不知理解的对不对。

#4


Delete all Fro x1+x2+x3+……+xm=0 in 表
pack in 表

#5


例如c:\aaa.dbf,不确定有多少字段(都为数值型),要删除所有字段值同时为0的纪录。
use c:\aaa.dbf
fieldnum=afields(myarray,"aaa")  &&取得表中字段数和各字段名称(数组第一列为字段名)
con=myarray[1,1]+"=0" &&取第一个字段,形成条件字符串的开始部分
if fieldnum>1
  for n=2 to fieldnum
    con2=myarray[n,1]+"=0"
    con=con+space(1)+"and"+space(1)+con2
  endfor
endif
sele aaa
dele all for &con
pack

#6


lnNum=3
lcFilter="Where 0"
For lnI=1 To lnNum
    lcFilter=lcFilter+"+x"+Transform(lnI)
Endfor
lcFilter=lcFilter+"=0"
Delete From 表名 &lcFilter.

学习了~

#7


 谢谢各位热心的帮助

#8


十三豆先生你好,你误会我的意思了,都怪我说的不清楚,我的意思是每一个字段都为0,而不是加起来为0,如果加起来为0 ,会出现一个如果一个字段为-1,一个字段为1,而被错误选择,不过我还是得谢谢你。

#9


the command "scan endscan" is powerful,this is the first time I seem his power ,but I have not use it yet ,so I cann't understand it.Tonight I will try to know it,I must say THANKYOU for your help.thankyou 

#1


Didn't remember exactly VFP syntax, 


select tableName

scan
  bDelete = .T.
  for iField to m 
     sField = "X" + str(i)
     if (&sField != 0)
         bDelete = .F.
         exit
     endif
  next
  if (bDelete)
     Delete Recno()
  endif
endscan

#2


lnNum=3
lcFilter="Where 0"
For lnI=1 To lnNum
lcFilter=lcFilter+"+x"+Transform(lnI)
Endfor
lcFilter=lcFilter+"=0"
Delete From 表名 &lcFilter.

#3


你说的不是很清楚,也没有举例,所以不知理解的对不对。

#4


Delete all Fro x1+x2+x3+……+xm=0 in 表
pack in 表

#5


例如c:\aaa.dbf,不确定有多少字段(都为数值型),要删除所有字段值同时为0的纪录。
use c:\aaa.dbf
fieldnum=afields(myarray,"aaa")  &&取得表中字段数和各字段名称(数组第一列为字段名)
con=myarray[1,1]+"=0" &&取第一个字段,形成条件字符串的开始部分
if fieldnum>1
  for n=2 to fieldnum
    con2=myarray[n,1]+"=0"
    con=con+space(1)+"and"+space(1)+con2
  endfor
endif
sele aaa
dele all for &con
pack

#6


lnNum=3
lcFilter="Where 0"
For lnI=1 To lnNum
    lcFilter=lcFilter+"+x"+Transform(lnI)
Endfor
lcFilter=lcFilter+"=0"
Delete From 表名 &lcFilter.

学习了~

#7


 谢谢各位热心的帮助

#8


十三豆先生你好,你误会我的意思了,都怪我说的不清楚,我的意思是每一个字段都为0,而不是加起来为0,如果加起来为0 ,会出现一个如果一个字段为-1,一个字段为1,而被错误选择,不过我还是得谢谢你。

#9


the command "scan endscan" is powerful,this is the first time I seem his power ,but I have not use it yet ,so I cann't understand it.Tonight I will try to know it,I must say THANKYOU for your help.thankyou