Advantage Developer Zone


Advantage Knowledgebase Item

Ref No:
Last Modified:
Tuesday, December 18, 2012
Advantage Clients ( General )
What is the Difference Between an "Empty Value" and NULL for a Visual FoxPro (VFP) Table?
Problem Description:
How does a client know the difference between a "blank" or "empty value" vs. a NULL value in a Visual FoxPro (VFP) table? In one case a numeric field displays nothing or blank in Advantage Data Architect, but using the .NET Data Provider a '0' is displayed.
From the documentation (Null Field Values): By default, fields in VFP tables are initialized to an empty value (e.g., zero for numeric fields). Also it is stated (Support for Null Values): By default, a VFP field that can be NULL is not set to NULL when a new record is appended, the field value must be specifically set to NULL.

A field in a VFP table must have the nullable property set to Yes or True to enable NULL values (AdsIsNullable), this property can be modified in Advantage Data Architect in the Properties of a table under the Fields tab. When this property is set there is an invisible system field (_NullFlags) that stores whether or not a nullable field is null, also known as the null status. This is part of the Visual FoxPro table file structure definition as defined here by Microsoft: Visual FoxPro 9.0 SP2 Table File Structure

The actual data stored in the nullable field itself doesn't change. The Advantage client checks the invisible system field to determine whether to send an "empty value" or NULL back to the client application.

As mentioned above a nullable VFP field is not set to NULL by default when appending a new record. A NULL must explicitly be specified. A SQL statement can be used to update a record to NULL.
Was This Item Helpful?