When using “CheckRules” and “DbReadNoData” to check the validity of fields, it should always be kept in mind, that a “DbReadNoData” like a “DbRead” might return a negative return code in case of a successful completion.
Thus, the sequence
DbReadNoData ( . . . . ) If Errorcode <> 0 then Error( "NOTFOUND" ) Else Reraise EndIf
might create an erroneous check result. The corrected sequence would be
DbReadNoData ( . . . . ) if Errorcode = TdOdbcNotFound then Error( "NOTFOUND" ) Else Reraise EndIf
To clarify this handling, the meaning of the different error codes
Errorcode < 0 → successful execution of the command with additional information
Errorcode = 0 → successful execution of the command without additional information
Errorcode > 0 → unsuccessful execution of the command or system error
Thus normal 'Ifs' are
If Errorcode <= 0 then → record found
If Errorcode = TdOdbcNotFound then → record not found