为了防止显示结果,只需为结果指定一个目标。 “进入数组”或“进入光标”就可以了。
根据您当前的代码,您对返回的行不感兴趣,因此您可以简单地获取计数(代码中也有错字)。即:
procedure checkForBadRecord
local array laBadCount[1]
select count(*) ;
from table_x ;
where field_x = "thing used to determine it's bad" ;
into array laBadCount
use in (select('table_x'))
if laBadCount[1] > 0 then
messagebox("Check the table for errors!")
endif
endproc
您可能不想编写这样的过程,而是希望编写此过程以用于更通用的用途:
if checkForBadRecord('table_x', 'field_x', "thing used to determine it's bad")
messagebox("Check the table table_x for errors!")
endif
procedure checkForBadRecord(tcTableName, tcFieldToCheck, tuValueToCheck)
local array laBadCount[1]
select count(*) ;
from &tcTableName ;
where &tcFieldToCheck = m.tuValueToCheck ;
into array laBadCount
use in (select(m.tcTableName))
return laBadCount[1] > 0
endproc
注意:您也可以使用“To Screen”来抑制结果并通过 _Tally 获取计数。即:
procedure checkForBadRecord
set console OFF
select * ;
from table_x ;
where field_x = "thing used to determine it's bad" ;
to SCREEN
set console ON
use in (select('table_x'))
if _Tally > 0 then
messagebox("Check the table for errors!")
endif
endproc