在 foxpro9 中检查空值和非空值

Checking Null values and Not null values in foxpro9

我从 SQL 服务器获取了一些字段到我的 Foxpro 游标中,如下所示。

stra="SELECT  cCm_Sgl_TaxInv,cInvNo FROM MIS.dbo.vInvFinalAll where cInvNo=?thisform.txtInvoiceNo.value"

SQLEXEC(hndOps,stra,'TaxInv')

而且我需要使用 IF 条件检查空值而不是空值。我写了下面的代码,但没有给出预期的结果。

SELECT TaxInv
IF NOT ISNULL(cCm_Sgl_TaxInv)
ELSE
ISNULL(cCm_Sgl_TaxInv)
thisform.cmdCreate.Enabled = .T. 
MESSAGEBOX("The value is already inserted")
endif

我该怎么做?

您似乎只需要在值为 null 时执行某些操作,因此假设:

  1. 'taxinv'游标将只有一条记录。

  2. 您只想在值为 null 时启用命令按钮

    select taxinv 如果为空(taxinv.cCm_Sgl_TaxInv) thisform.cmdCreate.Enabled =.t。 别的 messagebox("该值已经插入。") 结尾

不是很清楚你问的是什么,检查你的代码,可能是这个意思:

IF ISNULL(TaxInv.cCm_Sgl_TaxInv)
   thisform.cmdCreate.Enabled = .T. 
   MESSAGEBOX("The value is already inserted")
endif

编辑:这对于您尝试做的事情来说可能更简单:

text to m.stra noshow

SELECT case when cCm_Sgl_TaxInv is null then 1 else 0 end as txStatus
FROM MIS.dbo.vInvFinalAll 
where cInvNo=?thisform.txtInvoiceNo.value

endtext
SQLEXEC(m.hndOps,m.stra,'TaxInv')

if (TaxInv.txStatus = 1)
       thisform.cmdCreate.Enabled = .T. 
       MESSAGEBOX("The value is already inserted")
endif